ATLAS Offline Software
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 
17 
19 
20  int numStripCell = 0;
21 
22  double sumCellET = 0.;
23  double sumCellET01 = 0;
24  double sumCellET12 = 0.;
25  double sumStripET = 0.;
26  double sumEMCellET = 0.;
27  double sumHadCellET = 0.;
28  double stripEta = 0.;
29  double stripEta2 = 0.;
30  double EMRadius = 0.;
31  double HadRadius = 0.;
32 
33  std::vector<double> cellRingEnergys(7,0.);
34 
35  int numCells = 0;
36  std::bitset<200000> cellSeen;
37 
38  TLorentzVector tauAxis = tauRecTools::getTauAxis(pTau, m_doVertexCorrection);
39 
40  // loop over cells in all the clusters and calculate the variables
41  for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : pTau.vertexedClusters()){
42  const xAOD::CaloCluster& cluster = vertexedCluster.clust();
43  const CaloClusterCellLink* cellLinks = cluster.getCellLinks();
44  if (cellLinks == nullptr) {
45  ATH_MSG_DEBUG("NO Cell links found for cluster with pT " << cluster.pt());
46  continue;
47  }
48  for (const CaloCell* cell : *cellLinks) {
49  ++numCells;
50 
51  // cells could be used by more than one cluster, only count the cell one time
52  if (cellSeen.test(cell->caloDDE()->calo_hash())) {
53  continue;
54  }
55  else {
56  cellSeen.set(cell->caloDDE()->calo_hash());
57  }
58 
59  // cell four momentum corrected to point at the required vertex
60  double cellPhi = cell->phi();
61  double cellEta = cell->eta();
62  double cellET = cell->et();
63  double cellEnergy = cell->energy();
64 
65  const xAOD::Vertex* vertex = pTau.vertex();
66  if (m_doVertexCorrection && vertex!=nullptr) {
67  CaloVertexedCell vxCell (*cell, vertex->position());
68  cellPhi = vxCell.phi();
69  cellEta = vxCell.eta();
70  cellET = vxCell.et();
71  cellEnergy = vxCell.energy();
72  }
73 
74  TLorentzVector temp_cc_p4;
75  temp_cc_p4.SetPtEtaPhiE(cellET, cellEta, cellPhi, cellEnergy);
76  double dR = tauAxis.DeltaR(temp_cc_p4);
77 
78  if (dR < m_cellCone) {
79  sumCellET += cellET;
80 
81  if (dR < 0.1) sumCellET01 += cellET;
82  if (dR > 0.1 && dR < 0.2) sumCellET12 += cellET;
83 
84  CaloSampling::CaloSample calo = cell->caloDDE()->getSampling();
85 
86  // EM layer: PreSamplerB, PreSamplerE, EMB1, EME1, EMB2, EME2
87  // Most energy of neutral particles are deposited in the first two EM laywers
88  // The third layer is regarded as HAD layber
89  if (isEMLayer(calo)) {
90  EMRadius += dR*cellET;
91  sumEMCellET += cellET;
92 
93  // Strip layer: EMB1 and EME1
94  if (isStripLayer(calo) && (std::abs(cellEta) < 2.5)) {
95  sumStripET += cellET;
96  stripEta += cellEta * cellET;
97  stripEta2 += pow(cellEta, 2) * cellET;
98  if (cellEnergy > m_stripEthr) numStripCell += 1;
99  }
100  } // end of EM cells
101  else {
102  HadRadius += dR*cellET;
103  sumHadCellET += cellET;
104  } // end of HAD cells
105  } // end of dR < m_cellCone
106 
107  if (dR < 0.05) cellRingEnergys[0] += cellET;
108  if (dR >= 0.05 && dR < 0.075) cellRingEnergys[1] += cellET;
109  if (dR >= 0.075 && dR < 0.1) cellRingEnergys[2] += cellET;
110  if (dR >= 0.1 && dR < 0.125) cellRingEnergys[3] += cellET;
111  if (dR >= 0.125 && dR < 0.15) cellRingEnergys[4] += cellET;
112  if (dR >= 0.15 && dR < 0.2) cellRingEnergys[5] += cellET;
113  if (dR >= 0.2 && dR < 0.4) cellRingEnergys[6] += cellET;
114  } // end of loop over cells
115  } // end of loop over clusters
116 
117  ATH_MSG_DEBUG(numCells << " cells in seed");
118 
119  pTau.setDetail(xAOD::TauJetParameters::numCells , static_cast<int> (numCells));
120  pTau.setDetail(xAOD::TauJetParameters::nStrip , numStripCell );
121  pTau.setDetail(xAOD::TauJetParameters::etEMAtEMScale , static_cast<float>( sumEMCellET ));
122  pTau.setDetail(xAOD::TauJetParameters::etHadAtEMScale , static_cast<float>( sumHadCellET ));
123  pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing1 , static_cast<float>( cellRingEnergys[0] ));
124  pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing2 , static_cast<float>( cellRingEnergys[1] ));
125  pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing3 , static_cast<float>( cellRingEnergys[2] ));
126  pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing4 , static_cast<float>( cellRingEnergys[3] ));
127  pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing5 , static_cast<float>( cellRingEnergys[4] ));
128  pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing6 , static_cast<float>( cellRingEnergys[5] ));
129  pTau.setDetail(xAOD::TauJetParameters::cellBasedEnergyRing7 , static_cast<float>( cellRingEnergys[6] ));
130 
131  // take care of the variables with division
132  // -- fraction of cell energy within [0,0.1] and [0.1,0.2]
133  if (std::abs(sumCellET) > 1e-6) {
134  pTau.setDetail(xAOD::TauJetParameters::centFrac , static_cast<float>( sumCellET01 / sumCellET ));
135  pTau.setDetail(xAOD::TauJetParameters::isolFrac , static_cast<float>( sumCellET12 / sumCellET ));
136  }
137  else {
138  pTau.setDetail(xAOD::TauJetParameters::centFrac , static_cast<float>( 0.0 ));
139  pTau.setDetail(xAOD::TauJetParameters::isolFrac , static_cast<float>( -1.0 ));
140  }
141 
142  // -- width of strip cells
143  double stripWidth2 = 0.0;
144  if (std::abs(sumStripET) > 1e-6) {
145  stripEta = stripEta / sumStripET;
146  stripEta2 = stripEta2 / sumStripET;
147  stripWidth2 = stripEta2 - stripEta * stripEta;
148  }
149  else {
150  stripWidth2 = -1.0;
151  }
152  pTau.setDetail(xAOD::TauJetParameters::stripWidth2 , static_cast<float>( stripWidth2));
153 
154  // -- cell weighted radius of EM cells
155  if (std::abs(sumEMCellET) > 1e-6) {
156  EMRadius = EMRadius / sumEMCellET;
157  }
158  else {
159  EMRadius = -1.0;
160  }
161  pTau.setDetail(xAOD::TauJetParameters::EMRadius , static_cast<float>( EMRadius ));
162 
163  // -- cell weighted radius of HAD cells
164  if (std::abs(sumHadCellET) > 1e-6) {
165  HadRadius = HadRadius / sumHadCellET;
166  }
167  else {
168  HadRadius = -1.0;
169  }
170  pTau.setDetail(xAOD::TauJetParameters::hadRadius , static_cast<float>( HadRadius ));
171 
172  return StatusCode::SUCCESS;
173 }
174 
175 #endif
xAOD::TauJetParameters::cellBasedEnergyRing4
@ cellBasedEnergyRing4
Ring 4: 0.10 < R < 0.125.
Definition: TauDefs.h:252
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CaloVertexedCell::eta
virtual double eta() const final
The pseudorapidity of the particle.
Definition: CaloVertexedCell.h:65
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
xAOD::TauJetParameters::cellBasedEnergyRing7
@ cellBasedEnergyRing7
Ring 7: 0.2 < R < 0.4.
Definition: TauDefs.h:258
CaloVertexedCell::energy
double energy() const
The energy of the particle.
Definition: CaloVertexedCell.h:89
tauRecTools::getTauAxis
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 ...
Definition: Reconstruction/tauRecTools/Root/HelperFunctions.cxx:33
TauRecToolBase
The base class for all tau tools.
Definition: TauRecToolBase.h:21
CaloVertexedCell::phi
virtual double phi() const final
The aximuthal angle of the particle.
Definition: CaloVertexedCell.h:68
xAOD::TauJetParameters::cellBasedEnergyRing1
@ cellBasedEnergyRing1
EM+TES final scale.
Definition: TauDefs.h:246
xAOD::TauJetParameters::cellBasedEnergyRing6
@ cellBasedEnergyRing6
Ring 6: 0.15 < R < 0.2.
Definition: TauDefs.h:256
xAOD::TauJetParameters::hadRadius
@ hadRadius
Get hadron calorimeter radius.
Definition: TauDefs.h:192
xAOD::TauJetParameters::stripWidth2
@ stripWidth2
Get strip width ^2.
Definition: TauDefs.h:202
xAOD::TauJetParameters::centFrac
@ centFrac
Get centrality fraction.
Definition: TauDefs.h:200
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:62
xAOD::TauJetParameters::etHadAtEMScale
@ etHadAtEMScale
Get Hadronic energy at EM scale.
Definition: TauDefs.h:196
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
TauCellVariables::m_doVertexCorrection
Gaudi::Property< bool > m_doVertexCorrection
Definition: TauCellVariables.h:41
TauCellVariables::m_cellCone
Gaudi::Property< double > m_cellCone
Definition: TauCellVariables.h:40
xAOD::TauJetParameters::cellBasedEnergyRing2
@ cellBasedEnergyRing2
Ring 2: 0.05 < R < 0.075.
Definition: TauDefs.h:248
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::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
TauCellVariables::m_stripEthr
Gaudi::Property< double > m_stripEthr
Definition: TauCellVariables.h:39
xAOD::TauJetParameters::cellBasedEnergyRing5
@ cellBasedEnergyRing5
Ring 5: 0.125 < R < 0.15.
Definition: TauDefs.h:254
xAOD::CaloCluster_v1::getCellLinks
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
Definition: CaloCluster_v1.cxx:829
xAOD::CaloCluster_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters)
Definition: CaloCluster_v1.cxx:247
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::TauJetParameters::nStrip
@ nStrip
Get number of strips.
Definition: TauDefs.h:204
TauCellVariables::isStripLayer
bool isStripLayer(const CaloSampling::CaloSample &calo) const
Check whether the CaloSample is a Strip layer.
Definition: TauCellVariables.h:60
xAOD::TauJet_v3::vertexedClusters
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters() const
Definition: TauJet_v3.cxx:586
xAOD::TauJetParameters::cellBasedEnergyRing3
@ cellBasedEnergyRing3
Ring 3: 0.075 < R < 0.10.
Definition: TauDefs.h:250
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
TauCellVariables::execute
virtual StatusCode execute(xAOD::TauJet &pTau) const override
Perform the calculation of cell variables for each tau candidate.
Definition: TauCellVariables.cxx:18
xAOD::TauJetParameters::numCells
@ numCells
Definition: TauDefs.h:171
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloVertexedCell
Evaluate cell kinematics with a different vertex.
Definition: CaloVertexedCell.h:37
xAOD::TauJet_v3::vertex
const Vertex * vertex() const
HelperFunctions.h
xAOD::TauJet_v3::setDetail
void setDetail(TauJetParameters::Detail detail, int value)
Definition: TauJet_v3.cxx:309
xAOD::TauJetParameters::isolFrac
@ isolFrac
Get isolation fraction.
Definition: TauDefs.h:198
TauCellVariables::isEMLayer
bool isEMLayer(const CaloSampling::CaloSample &calo) const
Check whether the CaloSample is a EM layer.
Definition: TauCellVariables.h:45
TauCellVariables::TauCellVariables
TauCellVariables(const std::string &name)
Constructor.
Definition: TauCellVariables.cxx:15
P4EEtaPhiMBase::et
virtual double et() const
transverse energy defined to be e*sin(theta)
Definition: P4EEtaPhiMBase.cxx:106
xAOD::CaloVertexedTopoCluster
Evaluate cluster kinematics with a different vertex / signal state.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloVertexedTopoCluster.h:38
TauCellVariables.h
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
xAOD::TauJetParameters::EMRadius
@ EMRadius
Get E_T radius.
Definition: TauDefs.h:190
CaloVertexedCell.h
Evaluate cell kinematics with a different vertex.
xAOD::TauJetParameters::etEMAtEMScale
@ etEMAtEMScale
Get EM energy at EM scale.
Definition: TauDefs.h:194