ATLAS Offline Software
TauAxisSetter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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  // In trigger, jet candidate does not have a vertex
66  const xAOD::Vertex* jetVertex = nullptr;
67  if (!inTrigger()) {
68  jetVertex = tauRecTools::getJetVertex(*jetSeed);
69  }
70 
71  // Redo the vertex correction when tau vertex is different from jet vertex
72  if (jetVertex != tau.vertex()) {
73 
74  // If seed jet has a vertex, then tau must have one
75  if (tau.vertex() == nullptr) {
76  ATH_MSG_WARNING("The seed jet has a vertex, while the tau candidate does not. It should not happen.");
77  return StatusCode::FAILURE;
78  }
79 
80  const xAOD::Vertex* tauVertex = tau.vertex();
81 
82  // Relative position of the tau vertex and jet vertex
83  Amg::Vector3D position = tauVertex->position();
84  if (jetVertex != nullptr) {
85  position -= jetVertex->position();
86  }
87 
88  // Barycenter at the tau vertex
89  TLorentzVector baryCenterTauVertex;
90 
91  // Loop over the jet constituents, and calculate the barycenter using the four momentum
92  // corrected to point at tau vertex
93  for (const xAOD::JetConstituent* constituent : constituents) {
94  baryCenterTauVertex += getVertexCorrectedP4(*constituent, position);
95  }
96  ATH_MSG_DEBUG("barycenter (eta, phi) at tau vertex: " << baryCenterTauVertex.Eta() << " " << baryCenterTauVertex.Phi());
97 
98  // Tau intermediate axis is the four momentum (corrected to point at tau vertex) of clusters
99  // within m_clusterCone of the barycenter
100  for (const xAOD::JetConstituent* constituent : constituents) {
101  TLorentzVector constituentP4 = getVertexCorrectedP4(*constituent, position);
102  if (baryCenterTauVertex.DeltaR(constituentP4) > m_clusterCone) continue;
103 
104  tauInterAxis += constituentP4;
105  }
106  }
107  else {
108  tauInterAxis = tauDetectorAxis;
109  }
110 
111  if (tauInterAxis.Pt() == 0.) {
112  ATH_MSG_DEBUG("this tau candidate does not have any constituent clusters!");
113  return StatusCode::FAILURE;
114  }
115 
116  ATH_MSG_DEBUG("tau axis:" << tauInterAxis.Pt()<< " " << tauInterAxis.Eta() << " " << tauInterAxis.Phi() << " " << tauInterAxis.E() );
117  tau.setP4(tauInterAxis.Pt(), tauInterAxis.Eta(), tauInterAxis.Phi(), tau.m());
118  tau.setP4(xAOD::TauJetParameters::IntermediateAxis, tauInterAxis.Pt(), tauInterAxis.Eta(), tauInterAxis.Phi(), tauInterAxis.M());
119  } // End of m_doVertexCorrection
120 
121  return StatusCode::SUCCESS;
122 }
123 
124 
125 
127  const Amg::Vector3D& position) const {
128  TLorentzVector vertexCorrectedP4;
129 
130  if (constituent.type() == xAOD::Type::CaloCluster) {
131  const xAOD::CaloCluster* cluster = static_cast<const xAOD::CaloCluster*>(constituent.rawConstituent());
132  vertexCorrectedP4 = xAOD::CaloVertexedTopoCluster(*cluster, position).p4();;
133  }
134  else if ( constituent->type() == xAOD::Type::FlowElement ) {
135  const xAOD::FlowElement* fe = static_cast<const xAOD::FlowElement*>( constituent->rawConstituent() );
136  vertexCorrectedP4 = getVertexCorrectedP4(*fe, position);
137  }
138  else {
139  ATH_MSG_WARNING("Seed jet constituent type not supported, will not do vertex correction !");
140  vertexCorrectedP4 = tauRecTools::GetConstituentP4(constituent);
141  }
142 
143  return vertexCorrectedP4;
144 }
145 
147  const Amg::Vector3D& position) const {
148 
149  TLorentzVector vertexCorrectedP4;
150  // Only perfrom vertex corretion for neutral FlowElement
151  if (!fe.isCharged()) {
152  TVector3 pos(position.x(), position.y(), position.z());
153  vertexCorrectedP4 = FEHelpers::getVertexCorrectedFourVec(fe,pos);
154  }
155  else {
156  vertexCorrectedP4 = fe.p4();
157  }
158 
159  ATH_MSG_DEBUG("Original fe four momentum, pt: " << fe.pt() <<
160  " eta: " << fe.eta() << " phi: " << fe.phi() << " e: " << fe.e());
161  ATH_MSG_DEBUG("Vertex corrected four momentum, pt: " << vertexCorrectedP4.Pt() <<
162  " eta: " << vertexCorrectedP4.Eta() << " phi: " << vertexCorrectedP4.Phi() << " e: " << vertexCorrectedP4.E());
163 
164  return vertexCorrectedP4;
165 
166 }
167 
168 #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
TauRecToolBase::inTrigger
bool inTrigger() const
Definition: TauRecToolBase.h:87
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:172
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:59
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:221
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:18
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:126
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