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
18StatusCode TauCellVariables::execute(xAOD::TauJet& pTau) const {
19
20 double sumCellET = 0.;
21 double sumCellET01 = 0;
22 double sumCellET12 = 0.;
23 double sumEMCellET = 0.;
24 double sumHadCellET = 0.;
25
26 int numCells = 0;
27 //Local variable cellSeen uses 25000 bytes of stack space
28 //coverity[STACK_USE]
29 std::bitset<200000> cellSeen;
30
31 TLorentzVector tauAxis = tauRecTools::getTauAxis(pTau, m_doVertexCorrection);
32
33 // loop over cells in all the clusters and calculate the variables
34 for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : pTau.vertexedClusters()){
35 const xAOD::CaloCluster& cluster = vertexedCluster.clust();
36 const CaloClusterCellLink* cellLinks = cluster.getCellLinks();
37 if (cellLinks == nullptr) {
38 ATH_MSG_DEBUG("NO Cell links found for cluster with pT " << cluster.pt());
39 continue;
40 }
41 for (const CaloCell* cell : *cellLinks) {
42 ++numCells;
43
44 // cells could be used by more than one cluster, only count the cell one time
45 if (cellSeen.test(cell->caloDDE()->calo_hash())) {
46 continue;
47 }
48 else {
49 cellSeen.set(cell->caloDDE()->calo_hash());
50 }
51
52 // cell four momentum corrected to point at the required vertex
53 double cellPhi = cell->phi();
54 double cellEta = cell->eta();
55 double cellET = cell->et();
56 double cellEnergy = cell->energy();
57
58 const xAOD::Vertex* vertex = pTau.vertex();
59 if (m_doVertexCorrection && vertex!=nullptr) {
60 CaloVertexedCell vxCell (*cell, vertex->position());
61 cellPhi = vxCell.phi();
62 cellEta = vxCell.eta();
63 cellET = vxCell.et();
64 cellEnergy = vxCell.energy();
65 }
66
67 TLorentzVector temp_cc_p4;
68 temp_cc_p4.SetPtEtaPhiE(cellET, cellEta, cellPhi, cellEnergy);
69 double dR = tauAxis.DeltaR(temp_cc_p4);
70
71 if (dR < m_cellCone) {
72 sumCellET += cellET;
73
74 if (dR < 0.1) sumCellET01 += cellET;
75 if (dR > 0.1 && dR < 0.2) sumCellET12 += cellET;
76
77 CaloSampling::CaloSample calo = cell->caloDDE()->getSampling();
78
79 // EM layer: PreSamplerB, PreSamplerE, EMB1, EME1, EMB2, EME2
80 // Most energy of neutral particles are deposited in the first two EM laywers
81 // The third layer is regarded as HAD layber
82 if (isEMLayer(calo)) {
83 sumEMCellET += cellET;
84 } // end of EM cells
85 else {
86 sumHadCellET += cellET;
87 } // end of HAD cells
88 } // end of dR < m_cellCone
89 } // end of loop over cells
90 } // end of loop over clusters
91
92 ATH_MSG_DEBUG(numCells << " cells in seed");
93
94 pTau.setDetail(xAOD::TauJetParameters::numCells , static_cast<int> (numCells));
95 pTau.setDetail(xAOD::TauJetParameters::etEMAtEMScale , static_cast<float>( sumEMCellET ));
96 pTau.setDetail(xAOD::TauJetParameters::etHadAtEMScale , static_cast<float>( sumHadCellET ));
97
98 // take care of the variables with division
99 // -- fraction of cell energy within [0,0.1] and [0.1,0.2]
100 if (std::abs(sumCellET) > 1e-6) {
101 //coverity[DIVIDE_BY_ZERO:FALSE]
102 pTau.setDetail(xAOD::TauJetParameters::centFrac , static_cast<float>( sumCellET01 / sumCellET ));
103 //coverity[DIVIDE_BY_ZERO:FALSE]
104 pTau.setDetail(xAOD::TauJetParameters::isolFrac , static_cast<float>( sumCellET12 / sumCellET ));
105 }
106 else {
107 pTau.setDetail(xAOD::TauJetParameters::centFrac , static_cast<float>( 0.0 ));
108 pTau.setDetail(xAOD::TauJetParameters::isolFrac , static_cast<float>( -1.0 ));
109 }
110
111 return StatusCode::SUCCESS;
112}
113
114#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
TauCellVariables(const std::string &name)
Constructor.
virtual StatusCode execute(xAOD::TauJet &pTau) const override
Perform the calculation of cell variables for each tau candidate.
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