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