ATLAS Offline Software
xAODClusterCompressor.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // xAODClusterCompressor.cxx
8 // Implementation file for class xAODClusterCompressor
9 // Author: Walter Lampl
10 
12 
13 // CaloUtils includes
14 #include "xAODClusterCompressor.h"
15 #include <bitset>
16 
17 // Constructors
19 xAODClusterCompressor::xAODClusterCompressor(const std::string& name, ISvcLocator* pSvcLocator) :
20  base_class(name, pSvcLocator),
21  m_allMoments({{xAOD::CaloCluster::FIRST_PHI ,xAOD::CaloCluster::FIRST_ETA ,xAOD::CaloCluster::SECOND_R ,xAOD::CaloCluster::SECOND_LAMBDA ,xAOD::CaloCluster::DELTA_PHI ,xAOD::CaloCluster::DELTA_THETA ,xAOD::CaloCluster::DELTA_ALPHA ,xAOD::CaloCluster::CENTER_X ,xAOD::CaloCluster::CENTER_Y ,xAOD::CaloCluster::CENTER_Z ,xAOD::CaloCluster::CENTER_MAG ,xAOD::CaloCluster::CENTER_LAMBDA ,xAOD::CaloCluster::LATERAL ,xAOD::CaloCluster::LONGITUDINAL ,xAOD::CaloCluster::ENG_FRAC_EM ,xAOD::CaloCluster::ENG_FRAC_MAX ,xAOD::CaloCluster::ENG_FRAC_CORE ,xAOD::CaloCluster::FIRST_ENG_DENS ,xAOD::CaloCluster::SECOND_ENG_DENS ,xAOD::CaloCluster::ISOLATION ,xAOD::CaloCluster::ENG_BAD_CELLS ,xAOD::CaloCluster::N_BAD_CELLS ,xAOD::CaloCluster::N_BAD_CELLS_CORR ,xAOD::CaloCluster::BAD_CELLS_CORR_E ,xAOD::CaloCluster::BADLARQ_FRAC ,xAOD::CaloCluster::ENG_POS ,xAOD::CaloCluster::SIGNIFICANCE ,xAOD::CaloCluster::CELL_SIGNIFICANCE ,xAOD::CaloCluster::CELL_SIG_SAMPLING ,xAOD::CaloCluster::AVG_LAR_Q ,xAOD::CaloCluster::AVG_TILE_Q ,xAOD::CaloCluster::EM_PROBABILITY ,xAOD::CaloCluster::HAD_WEIGHT ,xAOD::CaloCluster::OOC_WEIGHT ,xAOD::CaloCluster::DM_WEIGHT ,xAOD::CaloCluster::TILE_CONFIDENCE_LEVEL ,xAOD::CaloCluster::VERTEX_FRACTION ,xAOD::CaloCluster::NVERTEX_FRACTION ,xAOD::CaloCluster::ENG_CALIB_TOT ,xAOD::CaloCluster::ENG_CALIB_OUT_L ,xAOD::CaloCluster::ENG_CALIB_OUT_M ,xAOD::CaloCluster::ENG_CALIB_OUT_T ,xAOD::CaloCluster::ENG_CALIB_DEAD_L ,xAOD::CaloCluster::ENG_CALIB_DEAD_M ,xAOD::CaloCluster::ENG_CALIB_DEAD_T ,xAOD::CaloCluster::ENG_CALIB_EMB0 ,xAOD::CaloCluster::ENG_CALIB_EME0 ,xAOD::CaloCluster::ENG_CALIB_TILEG3 ,xAOD::CaloCluster::ENG_CALIB_DEAD_TOT ,xAOD::CaloCluster::ENG_CALIB_DEAD_EMB0 ,xAOD::CaloCluster::ENG_CALIB_DEAD_TILE0 ,xAOD::CaloCluster::ENG_CALIB_DEAD_TILEG3 ,xAOD::CaloCluster::ENG_CALIB_DEAD_EME0 ,xAOD::CaloCluster::ENG_CALIB_DEAD_HEC0 ,xAOD::CaloCluster::ENG_CALIB_DEAD_FCAL ,xAOD::CaloCluster::ENG_CALIB_DEAD_LEAKAGE ,xAOD::CaloCluster::ENG_CALIB_DEAD_UNCLASS ,xAOD::CaloCluster::ENG_CALIB_FRAC_EM ,xAOD::CaloCluster::ENG_CALIB_FRAC_HAD ,xAOD::CaloCluster::ENG_CALIB_FRAC_REST}}),
22  //This listd DOES NOT contain the egamma-related moments: ETACALOFRAME, PHICALOFRAME, ETA1CALOFRAME, PHI1CALOFRAME, ETA2CALOFRAME, PHI2CALOFRAME
23  //Would be nicer to be jobO congfigurable (ideally per container) -> ENUMS? String-to-enum matching?
24  m_compressor(7)
25 
26 {
27  declareProperty( "Enable", m_isEnabled=true);
28 }
29 
30 
32  if (m_isEnabled)
33  ATH_MSG_INFO("Compression of ClusterMoments to 16 bits enabled");
34  else
35  ATH_MSG_INFO("Compression of ClusterMoments disabled");
36  return StatusCode::SUCCESS;
37 }
38 
39 
41 
42  if (!m_isEnabled) return;
43  if (clustercontainer->empty()) return;
44 
45  if (!clustercontainer->hasNonConstStore()) {
46  ATH_MSG_DEBUG("ClusterContainer has no non-const aux store. No compression.");
47  return;
48  }
49 
50  constexpr size_t nMoments=std::tuple_size<momentList_t>::value;
51 
52  std::bitset<nMoments> incompressibleMoments; //Idices of moments that are const or inexistant
53 
54 
55  for (xAOD::CaloCluster* cluster : *clustercontainer) { //Outer loop over clusters
56  for (size_t iMom=0; iMom<nMoments; ++iMom) { //Inner loop over moments
57  if (!incompressibleMoments.test(iMom)) {//Moment not (yet) known to be incompressible
58  double momValue;
60  if (cluster->retrieveMoment(mom,momValue)) {
61  cluster->insertMoment(mom,m_compressor.reduceFloatPrecision(momValue));
62  }
63  else {//moment doesn't exist
64  incompressibleMoments.set(iMom);
65  ATH_MSG_VERBOSE("Moment " << mom << " doesn not exists. Not attemps to compress it in subsequent clusters");
66  }
67  }//end if Moment not yet known to be incompressible
68  }//end loop over moments
69  }//end loop over clusters
70 }
xAOD::CaloCluster_v1::CENTER_MAG
@ CENTER_MAG
Cluster Centroid ( )
Definition: CaloCluster_v1.h:135
xAOD::CaloCluster_v1::SECOND_R
@ SECOND_R
Second Moment in .
Definition: CaloCluster_v1.h:123
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_UNCLASS
@ ENG_CALIB_DEAD_UNCLASS
Attached Calibration Hit energy in dead material in unclassified areas of the detector.
Definition: CaloCluster_v1.h:246
xAOD::CaloCluster_v1::FIRST_PHI
@ FIRST_PHI
First Moment in .
Definition: CaloCluster_v1.h:121
xAOD::CaloCluster_v1::OOC_WEIGHT
@ OOC_WEIGHT
Out-of-cluster weight (E_ooc/E_w)
Definition: CaloCluster_v1.h:175
xAOD::CaloCluster_v1::ENG_FRAC_CORE
@ ENG_FRAC_CORE
Energy fraction of the sum of the hottest cells in each sampling.
Definition: CaloCluster_v1.h:142
xAOD::CaloCluster_v1::VERTEX_FRACTION
@ VERTEX_FRACTION
Vertex fraction of this cluster wrt.
Definition: CaloCluster_v1.h:184
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::CaloCluster_v1::EM_PROBABILITY
@ EM_PROBABILITY
Classification probability to be em-like.
Definition: CaloCluster_v1.h:173
xAOD::CaloCluster_v1::CENTER_X
@ CENTER_X
Cluster Centroid ( )
Definition: CaloCluster_v1.h:131
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_LEAKAGE
@ ENG_CALIB_DEAD_LEAKAGE
Attached Calibration Hit energy in dead material behind calorimeters.
Definition: CaloCluster_v1.h:243
xAOD::CaloCluster_v1::AVG_LAR_Q
@ AVG_LAR_Q
Sum(E_cell_LAr^2 Q_cell_LAr)/Sum(E_cell_LAr^2)
Definition: CaloCluster_v1.h:163
xAOD::CaloCluster_v1::ENG_CALIB_TILEG3
@ ENG_CALIB_TILEG3
Calibration Hit energy inside the cluster scintillator.
Definition: CaloCluster_v1.h:222
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_T
@ ENG_CALIB_DEAD_T
Attached Calibration Hit energy in dead material with tight matching (Angle < 0.3).
Definition: CaloCluster_v1.h:214
xAOD::CaloCluster_v1::ENG_CALIB_OUT_M
@ ENG_CALIB_OUT_M
Attached Calibration Hit energy outside clusters but inside the calorimeter with medium matching (Ang...
Definition: CaloCluster_v1.h:200
xAOD::CaloCluster_v1::CENTER_LAMBDA
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
Definition: CaloCluster_v1.h:136
athena.value
value
Definition: athena.py:124
xAOD::CaloCluster_v1::ENG_CALIB_EMB0
@ ENG_CALIB_EMB0
Calibration Hit energy inside the cluster barrel presampler.
Definition: CaloCluster_v1.h:218
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_TILE0
@ ENG_CALIB_DEAD_TILE0
Attached Calibration Hit energy in dead material between EMB3 and TILE0.
Definition: CaloCluster_v1.h:230
xAOD::CaloCluster_v1::ENG_FRAC_MAX
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
Definition: CaloCluster_v1.h:140
xAODClusterCompressor::m_compressor
CxxUtils::FloatCompressor m_compressor
Definition: xAODClusterCompressor.h:40
xAOD::CaloCluster_v1::SECOND_LAMBDA
@ SECOND_LAMBDA
Second Moment in .
Definition: CaloCluster_v1.h:124
xAOD::CaloCluster_v1::MomentType
MomentType
Enums to identify different moments.
Definition: CaloCluster_v1.h:120
xAOD::CaloCluster_v1::CENTER_Z
@ CENTER_Z
Cluster Centroid ( )
Definition: CaloCluster_v1.h:133
xAOD::CaloCluster_v1::SECOND_ENG_DENS
@ SECOND_ENG_DENS
Second Moment in E/V.
Definition: CaloCluster_v1.h:144
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
xAOD::CaloCluster_v1::DM_WEIGHT
@ DM_WEIGHT
Dead-material weight (E_dm/E_ooc)
Definition: CaloCluster_v1.h:176
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
xAOD::CaloCluster_v1::HAD_WEIGHT
@ HAD_WEIGHT
Hadronic weight (E_w/E_em)
Definition: CaloCluster_v1.h:174
CxxUtils::FloatCompressor::reduceFloatPrecision
float reduceFloatPrecision(float value) const
Function returning a reduced precision float value.
Definition: FloatCompressor.cxx:98
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::CaloCluster_v1::CELL_SIG_SAMPLING
@ CELL_SIG_SAMPLING
CaloSample of the cell with the largest |E|/sig.
Definition: CaloCluster_v1.h:161
xAOD::CaloCluster_v1::ENG_CALIB_TOT
@ ENG_CALIB_TOT
Calibration Hit energy inside the cluster.
Definition: CaloCluster_v1.h:195
xAODClusterCompressor::initialize
virtual StatusCode initialize() override
Definition: xAODClusterCompressor.cxx:31
xAOD::CaloCluster_v1::ENG_CALIB_FRAC_EM
@ ENG_CALIB_FRAC_EM
Calibration Hit energy inside the cluster caused by e/gamma/pi0.
Definition: CaloCluster_v1.h:248
xAOD::CaloCluster_v1::ISOLATION
@ ISOLATION
Energy weighted fraction of non-clustered perimeter cells.
Definition: CaloCluster_v1.h:146
xAOD::CaloCluster_v1::ENG_CALIB_FRAC_REST
@ ENG_CALIB_FRAC_REST
Calibration Hit energy inside the cluster caused by other particles.
Definition: CaloCluster_v1.h:253
xAOD::CaloCluster_v1::DELTA_PHI
@ DELTA_PHI
Angular shower axis deviation ( ) from IP-to-Center.
Definition: CaloCluster_v1.h:126
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_FCAL
@ ENG_CALIB_DEAD_FCAL
Attached Calibration Hit energy in dead material before FCAL, between FCAL and HEC.
Definition: CaloCluster_v1.h:241
xAOD::CaloCluster_v1::FIRST_ENG_DENS
@ FIRST_ENG_DENS
First Moment in E/V.
Definition: CaloCluster_v1.h:143
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::CaloCluster_v1::ENG_BAD_CELLS
@ ENG_BAD_CELLS
Total em-scale energy of bad cells in this cluster.
Definition: CaloCluster_v1.h:148
xAOD::CaloCluster_v1::TILE_CONFIDENCE_LEVEL
@ TILE_CONFIDENCE_LEVEL
Confidence Level of a tile calorimeter cluster to be noise.
Definition: CaloCluster_v1.h:178
xAOD::CaloCluster_v1::ENG_CALIB_EME0
@ ENG_CALIB_EME0
Calibration Hit energy inside the cluster endcap presampler.
Definition: CaloCluster_v1.h:220
xAOD::CaloCluster_v1::ENG_FRAC_EM
@ ENG_FRAC_EM
Energy fraction in EM calorimeters.
Definition: CaloCluster_v1.h:139
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_M
@ ENG_CALIB_DEAD_M
Attached Calibration Hit energy in dead material with medium matching (Angle < 0.5).
Definition: CaloCluster_v1.h:211
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAODClusterCompressor::compress
virtual void compress(xAOD::CaloClusterContainer *clustercontainer) const override
Definition: xAODClusterCompressor.cxx:40
xAODClusterCompressor.h
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_HEC0
@ ENG_CALIB_DEAD_HEC0
Attached Calibration Hit energy in dead material between EME3 and HEC0.
Definition: CaloCluster_v1.h:238
xAOD::CaloCluster_v1::AVG_TILE_Q
@ AVG_TILE_Q
Sum(E_cell_Tile^2 Q_cell_Tile)/Sum(E_cell_Tile^2)
Definition: CaloCluster_v1.h:165
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_TILEG3
@ ENG_CALIB_DEAD_TILEG3
Attached Calibration Hit energy in dead material before scintillator.
Definition: CaloCluster_v1.h:232
xAOD::CaloCluster_v1::FIRST_ETA
@ FIRST_ETA
First Moment in .
Definition: CaloCluster_v1.h:122
xAODClusterCompressor::m_allMoments
momentList_t m_allMoments
Definition: xAODClusterCompressor.h:37
xAOD::CaloCluster_v1::DELTA_THETA
@ DELTA_THETA
Angular shower axis deviation ( ) from IP-to-Center.
Definition: CaloCluster_v1.h:128
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_TOT
@ ENG_CALIB_DEAD_TOT
Attached Calibration Hit energy in dead material.
Definition: CaloCluster_v1.h:224
xAODClusterCompressor::m_isEnabled
bool m_isEnabled
Definition: xAODClusterCompressor.h:43
xAOD::CaloCluster_v1::SIGNIFICANCE
@ SIGNIFICANCE
Cluster significance.
Definition: CaloCluster_v1.h:157
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_L
@ ENG_CALIB_DEAD_L
Attached Calibration Hit energy in dead material with loose matching (Angle < 1.0).
Definition: CaloCluster_v1.h:208
xAOD::CaloCluster_v1::LATERAL
@ LATERAL
Normalized lateral moment.
Definition: CaloCluster_v1.h:137
xAOD::CaloCluster_v1::DELTA_ALPHA
@ DELTA_ALPHA
Angular shower axis deviation ( ) from IP-to-Center.
Definition: CaloCluster_v1.h:130
xAOD::CaloCluster_v1::ENG_CALIB_FRAC_HAD
@ ENG_CALIB_FRAC_HAD
Calibration Hit energy inside the cluster caused by charged pi+ and pi-.
Definition: CaloCluster_v1.h:251
xAOD::CaloCluster_v1::CELL_SIGNIFICANCE
@ CELL_SIGNIFICANCE
Cell significance = E/sig of the cell with the largest |E|/sig.
Definition: CaloCluster_v1.h:159
xAOD::CaloCluster_v1::ENG_CALIB_OUT_L
@ ENG_CALIB_OUT_L
Attached Calibration Hit energy outside clusters but inside the calorimeter with loose matching (Angl...
Definition: CaloCluster_v1.h:196
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_EME0
@ ENG_CALIB_DEAD_EME0
Attached Calibration Hit energy in dead material before EME0, between EME0 and EME1.
Definition: CaloCluster_v1.h:235
xAODClusterCompressor::xAODClusterCompressor
xAODClusterCompressor()=delete
xAOD::CaloCluster_v1::ENG_CALIB_OUT_T
@ ENG_CALIB_OUT_T
Attached Calibration Hit energy outside clusters but inside the calorimeter with tight matching (Angl...
Definition: CaloCluster_v1.h:204
xAOD::CaloCluster_v1::BAD_CELLS_CORR_E
@ BAD_CELLS_CORR_E
Energy of bad cells with energy density average correction applied.
Definition: CaloCluster_v1.h:153
xAOD::CaloCluster_v1::N_BAD_CELLS_CORR
@ N_BAD_CELLS_CORR
Number of bad cells with energy density average correction applied.
Definition: CaloCluster_v1.h:151
xAOD::CaloCluster_v1::LONGITUDINAL
@ LONGITUDINAL
Normalized longitudinal moment.
Definition: CaloCluster_v1.h:138
xAOD::CaloCluster_v1::NVERTEX_FRACTION
@ NVERTEX_FRACTION
slightly updated vertex fraction more pile up independent (similar to nJVF)
Definition: CaloCluster_v1.h:185
xAOD::CaloCluster_v1::N_BAD_CELLS
@ N_BAD_CELLS
number of bad cells
Definition: CaloCluster_v1.h:149
xAOD::CaloCluster_v1::CENTER_Y
@ CENTER_Y
Cluster Centroid ( )
Definition: CaloCluster_v1.h:132
xAOD::CaloCluster_v1::ENG_CALIB_DEAD_EMB0
@ ENG_CALIB_DEAD_EMB0
Attached Calibration Hit energy in dead material before EMB0, between EMB0 and EMB1.
Definition: CaloCluster_v1.h:227
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
xAOD::CaloCluster_v1::ENG_POS
@ ENG_POS
Total positive Energy of this cluster.
Definition: CaloCluster_v1.h:156
xAOD::CaloCluster_v1::BADLARQ_FRAC
@ BADLARQ_FRAC
Energy fraction of LAr cells with quality larger than a given cut.
Definition: CaloCluster_v1.h:155