ATLAS Offline Software
Loading...
Searching...
No Matches
JetEMScaleMomTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <functional>
7
10
36
38
39 xAOD::JetFourMom_t emscaleSum;
40 // just sum 4-vectors:
41 for (auto iconstit=constits.begin(xAOD::UncalibratedJetConstituent); iconstit!=constits.end(xAOD::UncalibratedJetConstituent); ++iconstit) {
42 emscaleSum += **iconstit;
43 }
44 return emscaleSum;
45}
46
47//**********************************************************************
48
50: AsgTool(name) { }
51
52//**********************************************************************
53
55 ATH_MSG_INFO("Initializing JetEMScaleMomTool " << name());
56
57 if(m_jetContainerName.empty()){
58 ATH_MSG_ERROR("JetEMScaleMomTool needs to have its input jet container configured!");
59 return StatusCode::FAILURE;
60 }
61
62 std::vector<std::reference_wrapper<SG::WriteDecorHandleKey<xAOD::JetContainer> > > keys = {m_emscalePtKey, m_emscaleEtaKey, m_emscalePhiKey, m_emscaleMassKey};
64 key = m_jetContainerName + "." + key.key();
65 ATH_CHECK( key.initialize() );
66 }
67
68 ATH_MSG_DEBUG("Operating on jets with " << (m_useUncalibConstits ? "" : "un") << "calibrated constituents." );
69
70 return StatusCode::SUCCESS;
71}
72
73//**********************************************************************
74
75StatusCode JetEMScaleMomTool::decorate(const xAOD::JetContainer& jets) const {
76 ATH_MSG_VERBOSE("Begin decorating jets.");
78
79 for(const xAOD::Jet* jet : jets) {
81 // Need to loop and sum the constituents
82 xAOD::JetConstituentVector constits = jet->getConstituents();
83 if(! constits.isValid() ) {
84 ATH_MSG_WARNING("Jet constituent vector is invalid. Can't set EM scale momentum");
85 return StatusCode::FAILURE;
86 }
87 xAOD::JetFourMom_t em_p4 = getEMScaleP4(constits);
88 emscale_decor.decorateP4(*jet,em_p4);
89 } else {
90 // Simply add the constituent-level p4
92 emscale_decor.decorateP4(*jet,constit_p4);
93 }
94
95 }
96
97 return StatusCode::SUCCESS;
98}
99
100
101//**********************************************************************
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for adding a decoration to an object.
xAOD::JetFourMom_t getEMScaleP4(xAOD::JetConstituentVector &constits)
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Gaudi::Property< std::string > m_jetContainerName
JetEMScaleMomTool(const std::string &t)
SG::WriteDecorHandleKey< xAOD::JetContainer > m_emscalePtKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_emscalePhiKey
Gaudi::Property< bool > m_useUncalibConstits
SG::WriteDecorHandleKey< xAOD::JetContainer > m_emscaleMassKey
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_emscaleEtaKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Handle class for adding a decoration to an object.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
A vector of jet constituents at the scale used during jet finding.
iterator begin() const
iterator on the first constituent
bool isValid() const
Check if element links are valid.
iterator end() const
iterator after the last constituent
Jet_v1 Jet
Definition of the current "jet version".
@ JetConstitScaleMomentum
Definition JetTypes.h:29
JetContainer_v1 JetContainer
Definition of the current "jet container version".
@ UncalibratedJetConstituent
Definition JetTypes.h:21
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17
SG::WriteDecorHandle< xAOD::JetContainer, float > etaHandle
SG::WriteDecorHandle< xAOD::JetContainer, float > massHandle
SG::WriteDecorHandle< xAOD::JetContainer, float > phiHandle
p4Decorator(const SG::WriteDecorHandleKey< xAOD::JetContainer > &ptKey, const SG::WriteDecorHandleKey< xAOD::JetContainer > &etaKey, const SG::WriteDecorHandleKey< xAOD::JetContainer > &phiKey, const SG::WriteDecorHandleKey< xAOD::JetContainer > &massKey)
SG::WriteDecorHandle< xAOD::JetContainer, float > ptHandle
void decorateP4(const xAOD::Jet &jet, const xAOD::JetFourMom_t &p4)