ATLAS Offline Software
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 
10 #include "xAODPFlow/FlowElement.h"
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 
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 }
xAOD::FlowElement_v1::Neutral
@ Neutral
Definition: FlowElement_v1.h:37
xAOD::FlowElement_v1::Charged
@ Charged
Definition: FlowElement_v1.h:38
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
JetConstituentFrac::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition: JetConstituentFrac.h:34
xAOD::FlowElement_v1::pt
virtual double pt() const override
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JetConstituentFrac.h
JetConstituentFrac::m_chargeMFracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_chargeMFracKey
Definition: JetConstituentFrac.h:38
JetAccessorMap.h
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FlowElement.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition: FlowElement.h:16
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
xAOD::FlowElement_v1::signalType
signal_t signalType() const
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
JetConstituentFrac::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetConstituentFrac.cxx:19
JetConstituentFrac::m_chargePTFracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_chargePTFracKey
Definition: JetConstituentFrac.h:37
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
JetConstituentFrac::fillConstituentFrac
void fillConstituentFrac(const xAOD::Jet &jet) const
Definition: JetConstituentFrac.cxx:50
WriteDecorHandle.h
Handle class for adding a decoration to an object.
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
JetConstituentFrac::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition: JetConstituentFrac.cxx:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
xAOD::FlowElement_v1::e
virtual double e() const override
The total energy of the particle.
Definition: FlowElement_v1.cxx:25
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::FlowElement_v1::p4
virtual FourMom_t p4() const override
The full 4-momentum of the particle.
Definition: FlowElement_v1.cxx:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
JetConstituentFrac::JetConstituentFrac
JetConstituentFrac(const std::string &t)
Definition: JetConstituentFrac.cxx:14
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
JetConstituentFrac::m_neutralEFracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_neutralEFracKey
Definition: JetConstituentFrac.h:36
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25