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 double EMRadius = 0.;
26 double HadRadius = 0.;
27
28 std::vector<double> cellRingEnergys(7,0.);
29
30 int numCells = 0;
31 std::bitset<200000> cellSeen;
32
33 TLorentzVector tauAxis = tauRecTools::getTauAxis(pTau, m_doVertexCorrection);
34
35 // loop over cells in all the clusters and calculate the variables
36 for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : pTau.vertexedClusters()){
37 const xAOD::CaloCluster& cluster = vertexedCluster.clust();
38 const CaloClusterCellLink* cellLinks = cluster.getCellLinks();
39 if (cellLinks == nullptr) {
40 ATH_MSG_DEBUG("NO Cell links found for cluster with pT " << cluster.pt());
41 continue;
42 }
43 for (const CaloCell* cell : *cellLinks) {
44 ++numCells;
45
46 // cells could be used by more than one cluster, only count the cell one time
47 if (cellSeen.test(cell->caloDDE()->calo_hash())) {
48 continue;
49 }
50 else {
51 cellSeen.set(cell->caloDDE()->calo_hash());
52 }
53
54 // cell four momentum corrected to point at the required vertex
55 double cellPhi = cell->phi();
56 double cellEta = cell->eta();
57 double cellET = cell->et();
58 double cellEnergy = cell->energy();
59
60 const xAOD::Vertex* vertex = pTau.vertex();
61 if (m_doVertexCorrection && vertex!=nullptr) {
62 CaloVertexedCell vxCell (*cell, vertex->position());
63 cellPhi = vxCell.phi();
64 cellEta = vxCell.eta();
65 cellET = vxCell.et();
66 cellEnergy = vxCell.energy();
67 }
68
69 TLorentzVector temp_cc_p4;
70 temp_cc_p4.SetPtEtaPhiE(cellET, cellEta, cellPhi, cellEnergy);
71 double dR = tauAxis.DeltaR(temp_cc_p4);
72
73 if (dR < m_cellCone) {
74 sumCellET += cellET;
75
76 if (dR < 0.1) sumCellET01 += cellET;
77 if (dR > 0.1 && dR < 0.2) sumCellET12 += cellET;
78
79 CaloSampling::CaloSample calo = cell->caloDDE()->getSampling();
80
81 // EM layer: PreSamplerB, PreSamplerE, EMB1, EME1, EMB2, EME2
82 // Most energy of neutral particles are deposited in the first two EM laywers
83 // The third layer is regarded as HAD layber
84 if (isEMLayer(calo)) {
85 EMRadius += dR*cellET;
86 sumEMCellET += cellET;
87 } // end of EM cells
88 else {
89 HadRadius += dR*cellET;
90 sumHadCellET += cellET;
91 } // end of HAD cells
92 } // end of dR < m_cellCone
93
94 if (dR < 0.05) cellRingEnergys[0] += cellET;
95 if (dR >= 0.05 && dR < 0.075) cellRingEnergys[1] += cellET;
96 if (dR >= 0.075 && dR < 0.1) cellRingEnergys[2] += cellET;
97 if (dR >= 0.1 && dR < 0.125) cellRingEnergys[3] += cellET;
98 if (dR >= 0.125 && dR < 0.15) cellRingEnergys[4] += cellET;
99 if (dR >= 0.15 && dR < 0.2) cellRingEnergys[5] += cellET;
100 if (dR >= 0.2 && dR < 0.4) cellRingEnergys[6] += cellET;
101 } // end of loop over cells
102 } // end of loop over clusters
103
104 ATH_MSG_DEBUG(numCells << " cells in seed");
105
106 pTau.setDetail(xAOD::TauJetParameters::numCells , static_cast<int> (numCells));
107 pTau.setDetail(xAOD::TauJetParameters::etEMAtEMScale , static_cast<float>( sumEMCellET ));
108 pTau.setDetail(xAOD::TauJetParameters::etHadAtEMScale , static_cast<float>( sumHadCellET ));
109 pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing1 , static_cast<float>( cellRingEnergys[0] ));
110 pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing2 , static_cast<float>( cellRingEnergys[1] ));
111 pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing3 , static_cast<float>( cellRingEnergys[2] ));
112 pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing4 , static_cast<float>( cellRingEnergys[3] ));
113 pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing5 , static_cast<float>( cellRingEnergys[4] ));
114 pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing6 , static_cast<float>( cellRingEnergys[5] ));
115 pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing7 , static_cast<float>( cellRingEnergys[6] ));
116
117 // take care of the variables with division
118 // -- fraction of cell energy within [0,0.1] and [0.1,0.2]
119 if (std::abs(sumCellET) > 1e-6) {
120 pTau.setDetail(xAOD::TauJetParameters::centFrac , static_cast<float>( sumCellET01 / sumCellET ));
121 pTau.setDetail(xAOD::TauJetParameters::isolFrac , static_cast<float>( sumCellET12 / sumCellET ));
122 }
123 else {
124 pTau.setDetail(xAOD::TauJetParameters::centFrac , static_cast<float>( 0.0 ));
125 pTau.setDetail(xAOD::TauJetParameters::isolFrac , static_cast<float>( -1.0 ));
126 }
127
128 // -- cell weighted radius of EM cells
129 if (std::abs(sumEMCellET) > 1e-6) {
130 EMRadius = EMRadius / sumEMCellET;
131 }
132 else {
133 EMRadius = -1.0;
134 }
135 pTau.setDetail(xAOD::TauJetParameters::EMRadius , static_cast<float>( EMRadius ));
136
137 // -- cell weighted radius of HAD cells
138 if (std::abs(sumHadCellET) > 1e-6) {
139 HadRadius = HadRadius / sumHadCellET;
140 }
141 else {
142 HadRadius = -1.0;
143 }
144 pTau.setDetail(xAOD::TauJetParameters::hadRadius , static_cast<float>( HadRadius ));
145
146 return StatusCode::SUCCESS;
147}
148
149#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 ...
@ hadRadius
Get hadron calorimeter radius.
Definition TauDefs.h:192
@ EMRadius
Get E_T radius.
Definition TauDefs.h:190
@ etHadAtEMScale
Get Hadronic energy at EM scale.
Definition TauDefs.h:196
@ isolFrac
Get isolation fraction.
Definition TauDefs.h:198
@ cellBasedEnergyRing4
Ring 4: 0.10 < R < 0.125.
Definition TauDefs.h:252
@ cellBasedEnergyRing6
Ring 6: 0.15 < R < 0.2.
Definition TauDefs.h:256
@ cellBasedEnergyRing5
Ring 5: 0.125 < R < 0.15.
Definition TauDefs.h:254
@ cellBasedEnergyRing7
Ring 7: 0.2 < R < 0.4.
Definition TauDefs.h:258
@ etEMAtEMScale
Get EM energy at EM scale.
Definition TauDefs.h:194
@ centFrac
Get centrality fraction.
Definition TauDefs.h:200
@ cellBasedEnergyRing2
Ring 2: 0.05 < R < 0.075.
Definition TauDefs.h:248
@ cellBasedEnergyRing3
Ring 3: 0.075 < R < 0.10.
Definition TauDefs.h:250
@ cellBasedEnergyRing1
EM+TES final scale.
Definition TauDefs.h:246
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".