ATLAS Offline Software
Loading...
Searching...
No Matches
TauCellVariables.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef XAOD_ANALYSIS
6
7#include "TauCellVariables.h"
9
11
12#include <vector>
13
14
15TauCellVariables::TauCellVariables(const std::string& name) :
16 TauRecToolBase(name) {}
17
19 const EventContext& /*ctx*/) const {
20
21 double sumCellET = 0.;
22 double sumCellET01 = 0;
23 double sumCellET12 = 0.;
24 double sumEMCellET = 0.;
25 double sumHadCellET = 0.;
26
27 int numCells = 0;
28 //Local variable cellSeen uses 25000 bytes of stack space
29 //coverity[STACK_USE]
30 std::bitset<200000> cellSeen;
31
32 TLorentzVector tauAxis = tauRecTools::getTauAxis(pTau, m_doVertexCorrection);
33
34 // loop over cells in all the clusters and calculate the variables
35 for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : pTau.vertexedClusters()){
36 const xAOD::CaloCluster& cluster = vertexedCluster.clust();
37 const CaloClusterCellLink* cellLinks = cluster.getCellLinks();
38 if (cellLinks == nullptr) {
39 ATH_MSG_DEBUG("NO Cell links found for cluster with pT " << cluster.pt());
40 continue;
41 }
42 for (const CaloCell* cell : *cellLinks) {
43 ++numCells;
44
45 // cells could be used by more than one cluster, only count the cell one time
46 if (cellSeen.test(cell->caloDDE()->calo_hash())) {
47 continue;
48 }
49 else {
50 cellSeen.set(cell->caloDDE()->calo_hash());
51 }
52
53 // cell four momentum corrected to point at the required vertex
54 double cellPhi = cell->phi();
55 double cellEta = cell->eta();
56 double cellET = cell->et();
57 double cellEnergy = cell->energy();
58
59 const xAOD::Vertex* vertex = pTau.vertex();
60 if (m_doVertexCorrection && vertex!=nullptr) {
61 CaloVertexedCell vxCell (*cell, vertex->position());
62 cellPhi = vxCell.phi();
63 cellEta = vxCell.eta();
64 cellET = vxCell.et();
65 cellEnergy = vxCell.energy();
66 }
67
68 TLorentzVector temp_cc_p4;
69 temp_cc_p4.SetPtEtaPhiE(cellET, cellEta, cellPhi, cellEnergy);
70 double dR = tauAxis.DeltaR(temp_cc_p4);
71
72 if (dR < m_cellCone) {
73 sumCellET += cellET;
74
75 if (dR < 0.1) sumCellET01 += cellET;
76 if (dR > 0.1 && dR < 0.2) sumCellET12 += cellET;
77
78 CaloSampling::CaloSample calo = cell->caloDDE()->getSampling();
79
80 // EM layer: PreSamplerB, PreSamplerE, EMB1, EME1, EMB2, EME2
81 // Most energy of neutral particles are deposited in the first two EM laywers
82 // The third layer is regarded as HAD layber
83 if (isEMLayer(calo)) {
84 sumEMCellET += cellET;
85 } // end of EM cells
86 else {
87 sumHadCellET += cellET;
88 } // end of HAD cells
89 } // end of dR < m_cellCone
90 } // end of loop over cells
91 } // end of loop over clusters
92
93 ATH_MSG_DEBUG(numCells << " cells in seed");
94
95 pTau.setDetail(xAOD::TauJetParameters::numCells , static_cast<int> (numCells));
96 pTau.setDetail(xAOD::TauJetParameters::etEMAtEMScale , static_cast<float>( sumEMCellET ));
97 pTau.setDetail(xAOD::TauJetParameters::etHadAtEMScale , static_cast<float>( sumHadCellET ));
98
99 // take care of the variables with division
100 // -- fraction of cell energy within [0,0.1] and [0.1,0.2]
101 if (std::abs(sumCellET) > 1e-6) {
102 //coverity[DIVIDE_BY_ZERO:FALSE]
103 pTau.setDetail(xAOD::TauJetParameters::centFrac , static_cast<float>( sumCellET01 / sumCellET ));
104 //coverity[DIVIDE_BY_ZERO:FALSE]
105 pTau.setDetail(xAOD::TauJetParameters::isolFrac , static_cast<float>( sumCellET12 / sumCellET ));
106 }
107 else {
108 pTau.setDetail(xAOD::TauJetParameters::centFrac , static_cast<float>( 0.0 ));
109 pTau.setDetail(xAOD::TauJetParameters::isolFrac , static_cast<float>( -1.0 ));
110 }
111
112 return StatusCode::SUCCESS;
113}
114
115#endif
#define ATH_MSG_DEBUG(x,...)
Evaluate cell kinematics with a different vertex.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
Evaluate cell kinematics with a different vertex.
virtual double eta() const final
The pseudorapidity of the particle.
virtual double phi() const final
The aximuthal angle of the particle.
double energy() const
The energy of the particle.
virtual double et() const
transverse energy defined to be e*sin(theta)
bool isEMLayer(const CaloSampling::CaloSample &calo) const
Check whether the CaloSample is a EM layer.
Gaudi::Property< double > m_cellCone
Gaudi::Property< bool > m_doVertexCorrection
virtual StatusCode executeTool(xAOD::TauJet &pTau, const EventContext &ctx) const override
Execute - called for each tau candidate.
TauCellVariables(const std::string &name)
Constructor.
TauRecToolBase(const std::string &name)
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version).
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters).
Evaluate cluster kinematics with a different vertex / signal state.
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters() const
void setDetail(TauJetParameters::Detail detail, int value)
const Vertex * vertex() const
TLorentzVector getTauAxis(const xAOD::TauJet &tau, bool doVertexCorrection=true)
Return the four momentum of the tau axis The tau axis is widely used to select clusters and cells in ...
@ etHadAtEMScale
Get Hadronic energy at EM scale.
Definition TauDefs.h:196
@ isolFrac
Get isolation fraction.
Definition TauDefs.h:198
@ etEMAtEMScale
Get EM energy at EM scale.
Definition TauDefs.h:194
@ centFrac
Get centrality fraction.
Definition TauDefs.h:200
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Vertex_v1 Vertex
Define the latest version of the vertex class.
TauJet_v3 TauJet
Definition of the current "tau version".
Definition TauJet.h:17