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{};
69 double m_dRTruthJet{};
70 double m_recoGhostFrac{};
71 double m_dRTruthPart{};
72 double m_mLowTop{};
73 double m_mLowW{};
74 double m_mHighW{};
75 double m_mLowZ{};
76 double m_mHighZ{};
77
108 friend struct DecorHandles;
109
111 StatusCode labelTruthJets( DecorHandles& dh,
112 const EventContext& ctx ) const;
113 StatusCode labelTruthJets( DecorHandles& dh,
114 const xAOD::JetContainer &jets,
115 const EventContext& ctx ) const;
116
118 StatusCode labelRecoJets(DecorHandles& dh,
119 const xAOD::JetContainer &jets,
120 const EventContext& ctx) const;
121
124 const xAOD::Jet &jet,
125 const std::vector<std::pair<TLorentzVector,int> >& tlv_truthParts,
126 const EventContext& ctx ) const;
127
130 const xAOD::Jet &jet,
131 const EventContext& ctx ) const;
132
134 int getLabel( DecorHandles& dh,
135 const xAOD::Jet &jet, bool matchH, bool matchW, bool matchZ, bool matchTop,
136 const EventContext& ctx ) const;
137
139 float getWZSplit12Cut( float pt ) const;
140
142 float getTopSplit23Cut( float pt ) const;
143
145 int getNGhostParticles( const xAOD::Jet &jet, std::string collection ) const;
146
148 bool getIsSherpa( const int DSID ) const {
149 if(
150 (304307 <= DSID && DSID <= 304309) || // Sherpa 2.2.1 W+jets
151 (304707 <= DSID && DSID <= 304709) // Sherpa 2.2.1 Z+jets
152 ) {
153 return true;
154 }
155 return false;
156 };
157
159 void getTLVs( std::vector< std::pair<TLorentzVector,int> > &tlvs, const xAOD::TruthParticleContainer *truthBosons, const xAOD::TruthParticleContainer *truthTop, bool isSherpa = false ) const;
160
162 bool selectTruthParticle( const xAOD::TruthParticle *tp, int pdgId ) const;
163
173
174 TruthLabelConfiguration parseLabel(const std::string& label);
176
177 SG::WriteDecorHandleKey<xAOD::JetContainer> m_label_truthKey{this, "label_TruthKey", "", "Do not configure manually!"};
178 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_W_truthKey{this, "dR_W_TruthKey", "", "Do not configure manually!"};
179 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_Z_truthKey{this, "dR_Z_TruthKey", "", "Do not configure manually!"};
180 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_H_truthKey{this, "dR_H_TruthKey", "", "Do not configure manually!"};
181 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_Top_truthKey{this, "dR_Top_TruthKey", "", "Do not configure manually!"};
182 SG::WriteDecorHandleKey<xAOD::JetContainer> m_NB_truthKey{this, "NB_TruthKey", "", "Do not configure manually!"};
183 SG::ReadDecorHandleKey<xAOD::JetContainer> m_split12_truthKey{this, "Split12_TruthKey", "", "Do not configure manually!"};
184 SG::ReadDecorHandleKey<xAOD::JetContainer> m_split23_truthKey{this, "Split23_TruthKey", "", "Do not configure manually!"};
185
186 SG::WriteDecorHandleKey<xAOD::JetContainer> m_label_recoKey{this, "label_RecoKey", "", "Do not configure manually!"};
187 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_W_recoKey{this, "dR_W_RecoKey", "", "Do not configure manually!"};
188 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_Z_recoKey{this, "dR_Z_RecoKey", "", "Do not configure manually!"};
189 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_H_recoKey{this, "dR_H_RecoKey", "", "Do not configure manually!"};
190 SG::WriteDecorHandleKey<xAOD::JetContainer> m_dR_Top_recoKey{this, "dR_Top_RecoKey", "", "Do not configure manually!"};
191 SG::WriteDecorHandleKey<xAOD::JetContainer> m_NB_recoKey{this, "NB_RecoKey", "", "Do not configure manually!"};
192 SG::WriteDecorHandleKey<xAOD::JetContainer> m_truthSplit12_recoKey{this, "TruthSplit12_RecoKey", "", "Do not configure manually!"};
193 SG::WriteDecorHandleKey<xAOD::JetContainer> m_truthSplit23_recoKey{this, "TruthSplit23_RecoKey", "", "Do not configure manually!"};
194
195 SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedTruthJetMass_recoKey{this, "MatchedTruthJetMass_RecoKey", "", "Do not configure manually!"};
196 SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedTruthJetPt_recoKey{this, "MatchedTruthJetPt_RecoKey", "", "Do not configure manually!"};
197 SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedTruthJetEta_recoKey{ this, "MatchedTruthJetEta_RecoKey", "", "Do not configure manually!" };
198 SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedTruthJetPhi_recoKey{ this, "MatchedTruthJetPhi_RecoKey", "", "Do not configure manually!" };
199 SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedTruthJetDR_recoKey{ this, "MatchedTruthJetDR_RecoKey", "", "Do not configure manually!" };
200 SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedTruthJetGF_recoKey{ this, "MatchedTruthJetGF_RecoKey", "", "Do not configure manually!" };
201
202 SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedTruthGroomedJetMass_recoKey{this, "MatchedTruthGroomedJetMass_RecoKey", "", "Do not configure manually!"};
203 SG::WriteDecorHandleKey<xAOD::JetContainer> m_matchedTruthGroomedJetPt_recoKey{this, "MatchedTruthGroomedJetPt_RecoKey", "", "Do not configure manually!"};
204};
205
206#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.
@ Unknown
Definition TruthClasses.h:9
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.
double m_dRTruthPart
Ghost pT fraction to match truth jet to reco jet.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_matchedTruthJetDR_recoKey
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_matchedTruthJetPt_recoKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_label_recoKey
StatusCode labelTruthJets(DecorHandles &dh, const EventContext &ctx) const
Label truth jet collection.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_matchedTruthJetEta_recoKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_matchedTruthJetPhi_recoKey
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.
bool m_useGhostJetMatch
Use upper mass cut for W/Z labels.
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_matchedTruthJetMass_recoKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_H_recoKey
double m_recoGhostFrac
dR to match truth jet to reco jet
Gaudi::Property< bool > m_isTruthJetCol
TruthLabelConfiguration m_truthLabelConfig
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::WriteDecorHandleKey< xAOD::JetContainer > m_matchedTruthJetGF_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
SG::WriteDecorHandleKey< xAOD::JetContainer > m_matchedTruthGroomedJetMass_recoKey
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 ghost association to match reco to truth jets, dR otherwise.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_Z_recoKey
TruthLabelConfiguration parseLabel(const std::string &label)
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_dR_W_recoKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dR_Top_truthKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_matchedTruthGroomedJetPt_recoKey
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
std::string label(const std::string &format, int i)
Definition label.h:19
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