ATLAS Offline Software
Loading...
Searching...
No Matches
JetConstituentFrac.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
11
12//**********************************************************************
13
15: AsgTool(name) { }
16
17//**********************************************************************
18
20 ATH_MSG_INFO("Initializing JetConstituentFrac " << name());
21
22 if(m_jetContainerName.empty()){
23 ATH_MSG_ERROR("JetConstituentFrac needs to have its input jet container configured!");
24 return StatusCode::FAILURE;
25 }
26
30
31 ATH_CHECK(m_neutralEFracKey.initialize());
32 ATH_CHECK(m_chargePTFracKey.initialize());
33 ATH_CHECK(m_chargeMFracKey.initialize());
34
35 return StatusCode::SUCCESS;
36}
37
38//**********************************************************************
39
40StatusCode JetConstituentFrac::decorate(const xAOD::JetContainer& jets) const {
41 ATH_MSG_VERBOSE("Begin decorating jets.");
42 for(const xAOD::Jet* jet : jets) {
43
45
46 }
47 return StatusCode::SUCCESS;
48}
49
51
52 float neutE=0;
53 float chargPt=0;
54 TLorentzVector chargM = {0., 0., 0., 0.};
55
56 size_t numConstit = jet.numConstituents();
57 for ( size_t i=0; i<numConstit; i++ ) {
58 if(jet.rawConstituent(i)->type()!=xAOD::Type::FlowElement) {
59 ATH_MSG_WARNING("Tried to call fillConstituentFrac with a jet constituent that is not a FlowElement!");
60 continue;
61 }
62 const xAOD::FlowElement* constit = static_cast<const xAOD::FlowElement*>(jet.rawConstituent(i));
63
64 if(constit->signalType() == xAOD::FlowElement::Neutral) neutE+= constit->e();
65 if (constit->signalType() == xAOD::FlowElement::Charged){
66 chargPt += constit->pt();
67 chargM += constit->p4();
68 }
69 }
70
74
75 // Get jet p4 at constituent scale to compute ratios
76 xAOD::JetFourMom_t uncalP4;
77 jet.getAttribute<xAOD::JetFourMom_t>("JetConstitScaleMomentum",uncalP4);
78
79 neutralEFracHandle(jet) = neutE/uncalP4.e();
80 chargePTFracHandle(jet) = chargPt/uncalP4.pt();
81 chargeMFracHandle(jet) = uncalP4.M() != 0. ? chargM.M()/uncalP4.M() : 0.;
82
83}
#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)
Handle class for adding a decoration to an object.
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_chargeMFracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_neutralEFracKey
Gaudi::Property< std::string > m_jetContainerName
JetConstituentFrac(const std::string &t)
SG::WriteDecorHandleKey< xAOD::JetContainer > m_chargePTFracKey
void fillConstituentFrac(const xAOD::Jet &jet) const
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
virtual double pt() const override
signal_t signalType() const
virtual double e() const override
The total energy of the particle.
virtual FourMom_t p4() const override
The full 4-momentum of the particle.
@ FlowElement
The object is a track-calo-cluster.
Definition ObjectType.h:52
Jet_v1 Jet
Definition of the current "jet version".
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16
JetContainer_v1 JetContainer
Definition of the current "jet container version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17