ATLAS Offline Software
TauAxisSetter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef XAOD_ANALYSIS
6 
7 #include "TauAxisSetter.h"
9 
12 #include "xAODTau/TauJet.h"
14 
15 
16 
17 TauAxisSetter::TauAxisSetter(const std::string& name) :
19 }
20 
22 
23  if (tau.jet() == nullptr) {
24  ATH_MSG_ERROR("Tau jet link is invalid.");
25  return StatusCode::FAILURE;
26  }
27 
28  const xAOD::Jet* jetSeed = tau.jet();
29 
30  // Barycenter is the sum of cluster p4 in the seed jet
31  TLorentzVector baryCenter;
32 
33  xAOD::JetConstituentVector constituents = jetSeed->getConstituents();
34  for (const xAOD::JetConstituent* constituent : constituents) {
35  baryCenter += tauRecTools::GetConstituentP4(*constituent);
36  }
37 
38  ATH_MSG_DEBUG("barycenter (eta, phi): " << baryCenter.Eta() << " " << baryCenter.Phi());
39 
40  // Detector axis is the total p4 of clusters within m_clusterCone core of the barycenter
41  TLorentzVector tauDetectorAxis;
42 
43  for (const xAOD::JetConstituent* constituent : constituents) {
44  TLorentzVector constituentP4 = tauRecTools::GetConstituentP4(*constituent);
45 
46  if (baryCenter.DeltaR(constituentP4) > m_clusterCone) continue;
47 
48  tauDetectorAxis += constituentP4;
49  }
50 
51  if (tauDetectorAxis.Pt() == 0. && !m_doVertexCorrection) {
52  ATH_MSG_DEBUG("this tau candidate does not have any constituent clusters!");
53  return StatusCode::FAILURE;
54  }
55 
56  ATH_MSG_DEBUG("detector axis:" << tauDetectorAxis.Pt()<< " " << tauDetectorAxis.Eta() << " " << tauDetectorAxis.Phi() << " " << tauDetectorAxis.E());
57  tau.setP4(tauDetectorAxis.Pt(), tauDetectorAxis.Eta(), tauDetectorAxis.Phi(), tau.m());
58  tau.setP4(xAOD::TauJetParameters::DetectorAxis, tauDetectorAxis.Pt(), tauDetectorAxis.Eta(), tauDetectorAxis.Phi(), tauDetectorAxis.M());
59 
60 
62  // Tau intermediate axis (corrected for tau vertex)
63  TLorentzVector tauInterAxis;
64 
65  const xAOD::Vertex* jetVertex = tauRecTools::getJetVertex(*jetSeed);
66 
67  // Redo the vertex correction when tau vertex is different from jet vertex
68  if (jetVertex != tau.vertex()) {
69 
70  // If seed jet has a vertex, then tau must have one
71  if (tau.vertex() == nullptr) {
72  ATH_MSG_WARNING("The seed jet has a vertex, while the tau candidate does not. It should not happen.");
73  return StatusCode::FAILURE;
74  }
75 
76  const xAOD::Vertex* tauVertex = tau.vertex();
77 
78  // Relative position of the tau vertex and jet vertex
79  Amg::Vector3D position = tauVertex->position();
80  if (jetVertex != nullptr) {
81  position -= jetVertex->position();
82  }
83 
84  // Barycenter at the tau vertex
85  TLorentzVector baryCenterTauVertex;
86 
87  // Loop over the jet constituents, and calculate the barycenter using the four momentum
88  // corrected to point at tau vertex
89  for (const xAOD::JetConstituent* constituent : constituents) {
90  baryCenterTauVertex += getVertexCorrectedP4(*constituent, position);
91  }
92  ATH_MSG_DEBUG("barycenter (eta, phi) at tau vertex: " << baryCenterTauVertex.Eta() << " " << baryCenterTauVertex.Phi());
93 
94  // Tau intermediate axis is the four momentum (corrected to point at tau vertex) of clusters
95  // within m_clusterCone of the barycenter
96  for (const xAOD::JetConstituent* constituent : constituents) {
97  TLorentzVector constituentP4 = getVertexCorrectedP4(*constituent, position);
98  if (baryCenterTauVertex.DeltaR(constituentP4) > m_clusterCone) continue;
99 
100  tauInterAxis += constituentP4;
101  }
102  }
103  else {
104  tauInterAxis = tauDetectorAxis;
105  }
106 
107  if (tauInterAxis.Pt() == 0.) {
108  ATH_MSG_DEBUG("this tau candidate does not have any constituent clusters!");
109  return StatusCode::FAILURE;
110  }
111 
112  ATH_MSG_DEBUG("tau axis:" << tauInterAxis.Pt()<< " " << tauInterAxis.Eta() << " " << tauInterAxis.Phi() << " " << tauInterAxis.E() );
113  tau.setP4(tauInterAxis.Pt(), tauInterAxis.Eta(), tauInterAxis.Phi(), tau.m());
114  tau.setP4(xAOD::TauJetParameters::IntermediateAxis, tauInterAxis.Pt(), tauInterAxis.Eta(), tauInterAxis.Phi(), tauInterAxis.M());
115  } // End of m_doVertexCorrection
116 
117  return StatusCode::SUCCESS;
118 }
119 
120 
121 
123  const Amg::Vector3D& position) const {
124  TLorentzVector vertexCorrectedP4;
125 
126  if (constituent.type() == xAOD::Type::CaloCluster) {
127  const xAOD::CaloCluster* cluster = static_cast<const xAOD::CaloCluster*>(constituent.rawConstituent());
128  vertexCorrectedP4 = xAOD::CaloVertexedTopoCluster(*cluster, position).p4();;
129  }
130  else if ( constituent->type() == xAOD::Type::FlowElement ) {
131  const xAOD::FlowElement* fe = static_cast<const xAOD::FlowElement*>( constituent->rawConstituent() );
132  vertexCorrectedP4 = getVertexCorrectedP4(*fe, position);
133  }
134  else {
135  ATH_MSG_WARNING("Seed jet constituent type not supported, will not do vertex correction !");
136  vertexCorrectedP4 = tauRecTools::GetConstituentP4(constituent);
137  }
138 
139  return vertexCorrectedP4;
140 }
141 
143  const Amg::Vector3D& position) const {
144 
145  TLorentzVector vertexCorrectedP4;
146  // Only perfrom vertex corretion for neutral FlowElement
147  if (!fe.isCharged()) {
148  TVector3 pos(position.x(), position.y(), position.z());
149  vertexCorrectedP4 = FEHelpers::getVertexCorrectedFourVec(fe,pos);
150  }
151  else {
152  vertexCorrectedP4 = fe.p4();
153  }
154 
155  ATH_MSG_DEBUG("Original fe four momentum, pt: " << fe.pt() <<
156  " eta: " << fe.eta() << " phi: " << fe.phi() << " e: " << fe.e());
157  ATH_MSG_DEBUG("Vertex corrected four momentum, pt: " << vertexCorrectedP4.Pt() <<
158  " eta: " << vertexCorrectedP4.Eta() << " phi: " << vertexCorrectedP4.Phi() << " e: " << vertexCorrectedP4.E());
159 
160  return vertexCorrectedP4;
161 
162 }
163 
164 #endif
tauRecTools::getJetVertex
const xAOD::Vertex * getJetVertex(const xAOD::Jet &jet)
Return the vertex of jet candidate.
Definition: Reconstruction/tauRecTools/Root/HelperFunctions.cxx:20
xAOD::CaloVertexedClusterBase::p4
virtual FourMom_t p4() const final
The full 4-momentum of the particle.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloVertexedClusterBase.h:88
xAOD::TauJet_v3::jet
const Jet * jet() const
xAOD::TauJetParameters::IntermediateAxis
@ IntermediateAxis
Definition: TauDefs.h:338
xAOD::TauJet_v3::m
virtual double m() const
The invariant mass of the particle.
tauRecTools::GetConstituentP4
TLorentzVector GetConstituentP4(const xAOD::JetConstituent &constituent)
Definition: Reconstruction/tauRecTools/Root/HelperFunctions.cxx:70
TauRecToolBase
The base class for all tau tools.
Definition: TauRecToolBase.h:21
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
xAOD::FlowElement_v1::phi
virtual double phi() const override
The azimuthal angle ( ) of the particle.
xAOD::FlowElement_v1::pt
virtual double pt() const override
xAOD::Jet_v1::getConstituents
JetConstituentVector getConstituents() const
Return a vector of consituents. The object behaves like vector<const IParticle*>. See JetConstituentV...
Definition: Jet_v1.cxx:147
xAOD::TauJet_v3::setP4
void setP4(double pt, double eta, double phi, double m)
Set methods for IParticle values.
Definition: TauJet_v3.cxx:171
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
TauJetAuxContainer.h
xAOD::FlowElement_v1::isCharged
bool isCharged() const
Definition: FlowElement_v1.cxx:56
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:62
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TauAxisSetter.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition: FlowElement.h:16
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
TauAxisSetter::m_doVertexCorrection
Gaudi::Property< bool > m_doVertexCorrection
Definition: TauAxisSetter.h:54
xAOD::JetConstituent::rawConstituent
const IParticle * rawConstituent() const
Access the real underlying IParticle.
Definition: JetConstituentVector.h:102
TauJetContainer.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::JetConstituent::type
Type::ObjectType type() const
The full 4-momentum of the particle.
Definition: JetConstituentVector.h:91
xAOD::FlowElement_v1::e
virtual double e() const override
The total energy of the particle.
Definition: FlowElement_v1.cxx:25
CaloVertexedTopoCluster.h
Evaluate cluster kinematics with a different vertex / signal state.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TauAxisSetter::m_clusterCone
Gaudi::Property< double > m_clusterCone
Definition: TauAxisSetter.h:53
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::FlowElement_v1::eta
virtual double eta() const override
The pseudorapidity ( ) of the particle.
xAOD::FlowElement_v1::p4
virtual FourMom_t p4() const override
The full 4-momentum of the particle.
Definition: FlowElement_v1.cxx:33
TauAxisSetter::execute
virtual StatusCode execute(xAOD::TauJet &tau) const override
Execution of this tool.
Definition: TauAxisSetter.cxx:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::TauJet_v3::vertex
const Vertex * vertex() const
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TauJet.h
HelperFunctions.h
TauAxisSetter::getVertexCorrectedP4
TLorentzVector getVertexCorrectedP4(const xAOD::JetConstituent &constituent, const Amg::Vector3D &position) const
Get the vertex corrected four momentum.
Definition: TauAxisSetter.cxx:122
xAOD::JetConstituent
4-vector of jet constituent at the scale used during jet finding.
Definition: JetConstituentVector.h:61
xAOD::JetConstituentVector
A vector of jet constituents at the scale used during jet finding.
Definition: JetConstituentVector.h:117
xAOD::TauJetParameters::DetectorAxis
@ DetectorAxis
Definition: TauDefs.h:337
xAOD::CaloVertexedTopoCluster
Evaluate cluster kinematics with a different vertex / signal state.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloVertexedTopoCluster.h:38
TauAxisSetter::TauAxisSetter
TauAxisSetter(const std::string &name)
Constructor.
Definition: TauAxisSetter.cxx:17
FEHelpers::getVertexCorrectedFourVec
TLorentzVector getVertexCorrectedFourVec(const xAOD::FlowElement &fe, const xAOD::Vertex &vertexToCorrectTo)
Definition: FEHelpers.cxx:13
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25