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  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
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::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
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::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
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