ATLAS Offline Software
Loading...
Searching...
No Matches
CaloTopoClusterFromTowerHelpers.h
Go to the documentation of this file.
1// -*- c++ -*-
2/* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */
3#ifndef CALOREC_CALOTOPOCLUSTERFROMTOWERHELPERS
4#define CALOREC_CALOTOPOCLUSTERFROMTOWERHELPERS
5
6#include "CaloGeoHelpers/CaloSampling.h"
7
9
10#include <cstdarg>
11#include <string>
12#include <map>
13
14#define _SNAMELU( NAME ) { CaloSampling::NAME , std::string( #NAME ) }
15#define _SIDLU( ID ) { std::string( #ID ) , CaloSampling::ID }
16
17#define _MNAMELU( NAME ) { xAOD::CaloCluster::NAME, std::string( #NAME ) }
18#define _MIDLU( ID ) { std::string( #ID ) , xAOD::CaloCluster::ID }
19
20class CaloCell;
21
22// namespace xAOD {
23// class CaloCluster;
24// }
25
31namespace CaloRec {
32 namespace Helpers {
35 typedef std::array<double,CaloSampling::Unknown> valarray_t;
36 typedef std::vector<bool> boolarray_t;
38
42 std::string fmtMsg(const char* fmt,...) ;//{
43 // char _buffer[1024];
44 // va_list args;
45 // va_start(args,fmt);
46 // vsprintf(_buffer,fmt,args);
47 // va_end(args);
48 // return std::string(_buffer);
49 // }
51
137
148 bool cellAccumulator(const CaloCell& rcell,CaloClusterSignalAccumulator& accum,double weight,bool onlyKine=false);
155 bool calculateKine(xAOD::CaloCluster* pClus,bool onlyKine=false);
157 } // Helpers
158
160 namespace Lookup {
163 static const std::map<CaloSampling::CaloSample,std::string> samplingNames = {
164 // EM
165 _SNAMELU( PreSamplerB ), _SNAMELU( EMB1 ), _SNAMELU( EMB2 ), _SNAMELU( EMB3 ),
166 _SNAMELU( PreSamplerE ), _SNAMELU( EME1 ), _SNAMELU( EME2 ), _SNAMELU( EME3 ),
167 // HAD
168 _SNAMELU( HEC0 ), _SNAMELU( HEC1 ), _SNAMELU( HEC2 ), _SNAMELU( HEC3 ),
169 _SNAMELU( TileBar0 ), _SNAMELU( TileBar1 ), _SNAMELU( TileBar2 ),
170 // Tile
171 _SNAMELU( TileBar0 ), _SNAMELU( TileBar1 ), _SNAMELU( TileBar2 ),
172 _SNAMELU( TileGap1 ), _SNAMELU( TileGap2 ), _SNAMELU( TileGap3 ),
173 _SNAMELU( TileExt0 ), _SNAMELU( TileExt1 ), _SNAMELU( TileExt2 ),
174 // FCal
175 _SNAMELU( FCAL0 ), _SNAMELU( FCAL1 ), _SNAMELU( FCAL2 ),
176 // Mini-FCal
177 _SNAMELU( MINIFCAL0 ), _SNAMELU( MINIFCAL1 ), _SNAMELU( MINIFCAL2 ), _SNAMELU( MINIFCAL3 ),
178 // unknown
179 _SNAMELU( Unknown )
180 };
181 static const std::map<std::string,CaloSampling::CaloSample> samplingIds = {
182 // EM
183 _SIDLU( PreSamplerB ), _SIDLU( EMB1 ), _SIDLU( EMB2 ), _SIDLU( EMB3 ),
184 _SIDLU( PreSamplerE ), _SIDLU( EME1 ), _SIDLU( EME2 ), _SIDLU( EME3 ),
185 // HAD
186 _SIDLU( HEC0 ), _SIDLU( HEC1 ), _SIDLU( HEC2 ), _SIDLU( HEC3 ),
187 _SIDLU( TileBar0 ), _SIDLU( TileBar1 ), _SIDLU( TileBar2 ),
188 // Tile
189 _SIDLU( TileBar0 ), _SIDLU( TileBar1 ), _SIDLU( TileBar2 ),
190 _SIDLU( TileGap1 ), _SIDLU( TileGap2 ), _SIDLU( TileGap3 ),
191 _SIDLU( TileExt0 ), _SIDLU( TileExt1 ), _SIDLU( TileExt2 ),
192 // FCal
193 _SIDLU( FCAL0 ), _SIDLU( FCAL1 ), _SIDLU( FCAL2 ),
194 // Mini-FCal
195 _SIDLU( MINIFCAL0 ), _SIDLU( MINIFCAL1 ), _SIDLU( MINIFCAL2 ), _SIDLU( MINIFCAL3 ),
196 // unknown
197 _SIDLU( Unknown )
198 };
199 static const std::string& getSamplingName(CaloSampling::CaloSample sid);
200 static CaloSampling::CaloSample getSamplingId(const std::string& sname);
204 static const std::map<xAOD::CaloCluster::MomentType,std::string> clusterMomentNames = {
205 _MNAMELU( FIRST_PHI ),_MNAMELU( FIRST_ETA ),_MNAMELU( SECOND_R ),_MNAMELU( SECOND_LAMBDA ),_MNAMELU( DELTA_PHI ),_MNAMELU( DELTA_THETA ),_MNAMELU( DELTA_ALPHA ),
206 _MNAMELU( CENTER_X ),_MNAMELU( CENTER_Y ),_MNAMELU( CENTER_Z ),_MNAMELU( CENTER_MAG ),_MNAMELU( CENTER_LAMBDA ),_MNAMELU( LATERAL ),_MNAMELU( LONGITUDINAL ),
207 _MNAMELU( ENG_FRAC_EM ),_MNAMELU( ENG_FRAC_MAX ),_MNAMELU( ENG_FRAC_CORE ),_MNAMELU( FIRST_ENG_DENS ),_MNAMELU( SECOND_ENG_DENS ),_MNAMELU( ENG_POS ),
208 _MNAMELU( ISOLATION ),_MNAMELU( ENG_BAD_CELLS ),_MNAMELU( N_BAD_CELLS ),_MNAMELU( N_BAD_CELLS_CORR ),_MNAMELU( BAD_CELLS_CORR_E ),_MNAMELU( BADLARQ_FRAC ),
209 _MNAMELU( SIGNIFICANCE ),_MNAMELU( CELL_SIGNIFICANCE ),_MNAMELU( CELL_SIG_SAMPLING ),_MNAMELU( AVG_LAR_Q ),_MNAMELU( AVG_TILE_Q ),_MNAMELU( ENG_BAD_HV_CELLS ),
210 _MNAMELU( N_BAD_HV_CELLS ),_MNAMELU( PTD ),_MNAMELU( MASS ),_MNAMELU( EM_PROBABILITY ),_MNAMELU( HAD_WEIGHT ),_MNAMELU( OOC_WEIGHT ),_MNAMELU( DM_WEIGHT ),
211 _MNAMELU( TILE_CONFIDENCE_LEVEL ),_MNAMELU( VERTEX_FRACTION ),_MNAMELU( NVERTEX_FRACTION ),_MNAMELU( ETACALOFRAME ),_MNAMELU( PHICALOFRAME ),_MNAMELU( ETA1CALOFRAME ),
212 _MNAMELU( PHI1CALOFRAME ),_MNAMELU( ETA2CALOFRAME ),_MNAMELU( PHI2CALOFRAME ),_MNAMELU( ENG_CALIB_TOT ),_MNAMELU( ENG_CALIB_OUT_L ),_MNAMELU( ENG_CALIB_OUT_M ),
213 _MNAMELU( ENG_CALIB_OUT_T ),_MNAMELU( ENG_CALIB_DEAD_L ),_MNAMELU( ENG_CALIB_DEAD_M ),_MNAMELU( ENG_CALIB_DEAD_T ),_MNAMELU( ENG_CALIB_EMB0 ),_MNAMELU( ENG_CALIB_EME0 ),
214 _MNAMELU( ENG_CALIB_TILEG3 ),_MNAMELU( ENG_CALIB_DEAD_TOT ),_MNAMELU( ENG_CALIB_DEAD_EMB0 ),_MNAMELU( ENG_CALIB_DEAD_TILE0 ),_MNAMELU( ENG_CALIB_DEAD_TILEG3 ),
215 _MNAMELU( ENG_CALIB_DEAD_EME0 ),_MNAMELU( ENG_CALIB_DEAD_HEC0 ),_MNAMELU( ENG_CALIB_DEAD_FCAL ),_MNAMELU( ENG_CALIB_DEAD_LEAKAGE ),_MNAMELU( ENG_CALIB_DEAD_UNCLASS ),
216 _MNAMELU( ENG_CALIB_FRAC_EM ),_MNAMELU( ENG_CALIB_FRAC_HAD ),_MNAMELU( ENG_CALIB_FRAC_REST ),_MNAMELU( ENERGY_DigiHSTruth ),_MNAMELU( ETA_DigiHSTruth ),_MNAMELU( PHI_DigiHSTruth ),
217 _MNAMELU( TIME_DigiHSTruth ),_MNAMELU( ENERGY_CALIB_DigiHSTruth ),_MNAMELU( ETA_CALIB_DigiHSTruth ),_MNAMELU( PHI_CALIB_DigiHSTruth ),_MNAMELU( TIME_CALIB_DigiHSTruth ),
218 _MNAMELU( FIRST_PHI_DigiHSTruth ),_MNAMELU( FIRST_ETA_DigiHSTruth ),_MNAMELU( SECOND_R_DigiHSTruth ),_MNAMELU( SECOND_LAMBDA_DigiHSTruth ),_MNAMELU( DELTA_PHI_DigiHSTruth ),
219 _MNAMELU( DELTA_THETA_DigiHSTruth ),_MNAMELU( DELTA_ALPHA_DigiHSTruth ),_MNAMELU( CENTER_X_DigiHSTruth ),_MNAMELU( CENTER_Y_DigiHSTruth ),_MNAMELU( CENTER_Z_DigiHSTruth ),
220 _MNAMELU( CENTER_MAG_DigiHSTruth ),_MNAMELU( CENTER_LAMBDA_DigiHSTruth ),_MNAMELU( LATERAL_DigiHSTruth ),_MNAMELU( LONGITUDINAL_DigiHSTruth ),_MNAMELU( ENG_FRAC_EM_DigiHSTruth ),
221 _MNAMELU( ENG_FRAC_MAX_DigiHSTruth ),_MNAMELU( ENG_FRAC_CORE_DigiHSTruth ),_MNAMELU( FIRST_ENG_DENS_DigiHSTruth ),_MNAMELU( SECOND_ENG_DENS_DigiHSTruth ),
222 _MNAMELU( ISOLATION_DigiHSTruth ),_MNAMELU( ENG_BAD_CELLS_DigiHSTruth ),_MNAMELU( N_BAD_CELLS_DigiHSTruth ),_MNAMELU( N_BAD_CELLS_CORR_DigiHSTruth ),
223 _MNAMELU( BAD_CELLS_CORR_E_DigiHSTruth ),_MNAMELU( BADLARQ_FRAC_DigiHSTruth ),_MNAMELU( ENG_POS_DigiHSTruth ),_MNAMELU( SIGNIFICANCE_DigiHSTruth ),
224 _MNAMELU( CELL_SIGNIFICANCE_DigiHSTruth ),_MNAMELU( CELL_SIG_SAMPLING_DigiHSTruth ),_MNAMELU( AVG_LAR_Q_DigiHSTruth ),_MNAMELU( AVG_TILE_Q_DigiHSTruth ),
225 _MNAMELU( ENG_BAD_HV_CELLS_DigiHSTruth ),_MNAMELU( N_BAD_HV_CELLS_DigiHSTruth ),_MNAMELU( EM_PROBABILITY_DigiHSTruth ),_MNAMELU( HAD_WEIGHT_DigiHSTruth ),
226 _MNAMELU( OOC_WEIGHT_DigiHSTruth ),_MNAMELU( DM_WEIGHT_DigiHSTruth )
227 };
228 static const std::map<std::string,xAOD::CaloCluster::MomentType> clusterMomentTypes = {
229 _MIDLU( FIRST_PHI ),_MIDLU( FIRST_ETA ),_MIDLU( SECOND_R ),_MIDLU( SECOND_LAMBDA ),_MIDLU( DELTA_PHI ),_MIDLU( DELTA_THETA ),_MIDLU( DELTA_ALPHA ),
230 _MIDLU( CENTER_X ),_MIDLU( CENTER_Y ),_MIDLU( CENTER_Z ),_MIDLU( CENTER_MAG ),_MIDLU( CENTER_LAMBDA ),_MIDLU( LATERAL ),_MIDLU( LONGITUDINAL ),
231 _MIDLU( ENG_FRAC_EM ),_MIDLU( ENG_FRAC_MAX ),_MIDLU( ENG_FRAC_CORE ),_MIDLU( FIRST_ENG_DENS ),_MIDLU( SECOND_ENG_DENS ),_MIDLU( ENG_POS ),
232 _MIDLU( ISOLATION ),_MIDLU( ENG_BAD_CELLS ),_MIDLU( N_BAD_CELLS ),_MIDLU( N_BAD_CELLS_CORR ),_MIDLU( BAD_CELLS_CORR_E ),_MIDLU( BADLARQ_FRAC ),
233 _MIDLU( SIGNIFICANCE ),_MIDLU( CELL_SIGNIFICANCE ),_MIDLU( CELL_SIG_SAMPLING ),_MIDLU( AVG_LAR_Q ),_MIDLU( AVG_TILE_Q ),_MIDLU( ENG_BAD_HV_CELLS ),
234 _MIDLU( N_BAD_HV_CELLS ),_MIDLU( PTD ),_MIDLU( MASS ),_MIDLU( EM_PROBABILITY ),_MIDLU( HAD_WEIGHT ),_MIDLU( OOC_WEIGHT ),_MIDLU( DM_WEIGHT ),
235 _MIDLU( TILE_CONFIDENCE_LEVEL ),_MIDLU( VERTEX_FRACTION ),_MIDLU( NVERTEX_FRACTION ),_MIDLU( ETACALOFRAME ),_MIDLU( PHICALOFRAME ),_MIDLU( ETA1CALOFRAME ),
236 _MIDLU( PHI1CALOFRAME ),_MIDLU( ETA2CALOFRAME ),_MIDLU( PHI2CALOFRAME ),_MIDLU( ENG_CALIB_TOT ),_MIDLU( ENG_CALIB_OUT_L ),_MIDLU( ENG_CALIB_OUT_M ),
237 _MIDLU( ENG_CALIB_OUT_T ),_MIDLU( ENG_CALIB_DEAD_L ),_MIDLU( ENG_CALIB_DEAD_M ),_MIDLU( ENG_CALIB_DEAD_T ),_MIDLU( ENG_CALIB_EMB0 ),_MIDLU( ENG_CALIB_EME0 ),
238 _MIDLU( ENG_CALIB_TILEG3 ),_MIDLU( ENG_CALIB_DEAD_TOT ),_MIDLU( ENG_CALIB_DEAD_EMB0 ),_MIDLU( ENG_CALIB_DEAD_TILE0 ),_MIDLU( ENG_CALIB_DEAD_TILEG3 ),
239 _MIDLU( ENG_CALIB_DEAD_EME0 ),_MIDLU( ENG_CALIB_DEAD_HEC0 ),_MIDLU( ENG_CALIB_DEAD_FCAL ),_MIDLU( ENG_CALIB_DEAD_LEAKAGE ),_MIDLU( ENG_CALIB_DEAD_UNCLASS ),
240 _MIDLU( ENG_CALIB_FRAC_EM ),_MIDLU( ENG_CALIB_FRAC_HAD ),_MIDLU( ENG_CALIB_FRAC_REST ),_MIDLU( ENERGY_DigiHSTruth ),_MIDLU( ETA_DigiHSTruth ),_MIDLU( PHI_DigiHSTruth ),
241 _MIDLU( TIME_DigiHSTruth ),_MIDLU( ENERGY_CALIB_DigiHSTruth ),_MIDLU( ETA_CALIB_DigiHSTruth ),_MIDLU( PHI_CALIB_DigiHSTruth ),_MIDLU( TIME_CALIB_DigiHSTruth ),
242 _MIDLU( FIRST_PHI_DigiHSTruth ),_MIDLU( FIRST_ETA_DigiHSTruth ),_MIDLU( SECOND_R_DigiHSTruth ),_MIDLU( SECOND_LAMBDA_DigiHSTruth ),_MIDLU( DELTA_PHI_DigiHSTruth ),
243 _MIDLU( DELTA_THETA_DigiHSTruth ),_MIDLU( DELTA_ALPHA_DigiHSTruth ),_MIDLU( CENTER_X_DigiHSTruth ),_MIDLU( CENTER_Y_DigiHSTruth ),_MIDLU( CENTER_Z_DigiHSTruth ),
244 _MIDLU( CENTER_MAG_DigiHSTruth ),_MIDLU( CENTER_LAMBDA_DigiHSTruth ),_MIDLU( LATERAL_DigiHSTruth ),_MIDLU( LONGITUDINAL_DigiHSTruth ),_MIDLU( ENG_FRAC_EM_DigiHSTruth ),
245 _MIDLU( ENG_FRAC_MAX_DigiHSTruth ),_MIDLU( ENG_FRAC_CORE_DigiHSTruth ),_MIDLU( FIRST_ENG_DENS_DigiHSTruth ),_MIDLU( SECOND_ENG_DENS_DigiHSTruth ),
246 _MIDLU( ISOLATION_DigiHSTruth ),_MIDLU( ENG_BAD_CELLS_DigiHSTruth ),_MIDLU( N_BAD_CELLS_DigiHSTruth ),_MIDLU( N_BAD_CELLS_CORR_DigiHSTruth ),
247 _MIDLU( BAD_CELLS_CORR_E_DigiHSTruth ),_MIDLU( BADLARQ_FRAC_DigiHSTruth ),_MIDLU( ENG_POS_DigiHSTruth ),_MIDLU( SIGNIFICANCE_DigiHSTruth ),
248 _MIDLU( CELL_SIGNIFICANCE_DigiHSTruth ),_MIDLU( CELL_SIG_SAMPLING_DigiHSTruth ),_MIDLU( AVG_LAR_Q_DigiHSTruth ),_MIDLU( AVG_TILE_Q_DigiHSTruth ),
249 _MIDLU( ENG_BAD_HV_CELLS_DigiHSTruth ),_MIDLU( N_BAD_HV_CELLS_DigiHSTruth ),_MIDLU( EM_PROBABILITY_DigiHSTruth ),_MIDLU( HAD_WEIGHT_DigiHSTruth ),
250 _MIDLU( OOC_WEIGHT_DigiHSTruth ),_MIDLU( DM_WEIGHT_DigiHSTruth )
251 };
252 static const std::string& getMomentName(xAOD::CaloCluster::MomentType momentType);
253 static bool getMomentType(const std::string& momentName,xAOD::CaloCluster::MomentType& momentType);
254 static bool haveMomentType(const std::string& momentName);
256 } // Lookup
257} // CaloRec
258
260 auto it = samplingNames.find(sid);
261 if (it != samplingNames.end()) return it->second;
262 static const std::string unknown = "Unknown";
263 return unknown; }
265 auto it = samplingIds.find(sname);
266 if (it != samplingIds.end()) return it->second;
267 return CaloSampling::Unknown; }
268
269inline bool CaloRec::Lookup::haveMomentType(const std::string& momentName) { return clusterMomentTypes.contains(momentName); }
270inline const std::string& CaloRec::Lookup::getMomentName(xAOD::CaloCluster::MomentType momentType) { return clusterMomentNames.at(momentType); }
271inline bool CaloRec::Lookup::getMomentType(const std::string& momentName,xAOD::CaloCluster::MomentType& momentType) {
272 bool isOk(haveMomentType(momentName)); if ( isOk ) { momentType = clusterMomentTypes.at(momentName); } return isOk;
273}
274
275
276#endif
#define _MIDLU(ID)
#define _MNAMELU(NAME)
#define _SIDLU(ID)
#define _SNAMELU(NAME)
const char *const fmt
@ Unknown
Definition TruthClasses.h:9
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
MomentType
Enums to identify different moments.
bool cellAccumulator(const CaloCell &rcell, CaloClusterSignalAccumulator &accum, double weight, bool onlyKine=false)
std::vector< bool > boolarray_t
Vector of flags indicating sampling contribution.
bool calculateKine(xAOD::CaloCluster *pClus, bool onlyKine=false)
Kinematic updates.
std::array< double, CaloSampling::Unknown > valarray_t
Array accommodating data for samplings.
std::string fmtMsg(const char *fmt,...)
static const std::map< CaloSampling::CaloSample, std::string > samplingNames
Name lookup by sampling identifier (data)
static const std::map< xAOD::CaloCluster::MomentType, std::string > clusterMomentNames
Moment names by moment types.
static const std::map< std::string, CaloSampling::CaloSample > samplingIds
Identifier lookup by sampling name (data)
static const std::string & getSamplingName(CaloSampling::CaloSample sid)
Lookup sampling name by identifier (function)
static const std::string & getMomentName(xAOD::CaloCluster::MomentType momentType)
Get moment name associated with a moment type.
static const std::map< std::string, xAOD::CaloCluster::MomentType > clusterMomentTypes
Moment names buy moment identifiers.
static bool getMomentType(const std::string &momentName, xAOD::CaloCluster::MomentType &momentType)
Get moment type associated with a moment name.
static CaloSampling::CaloSample getSamplingId(const std::string &sname)
Lookup sampling identifier by name (function)
static bool haveMomentType(const std::string &momentName)
Returns true in case moment is known.
Namespace for helper functions.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
boolarray_t presenceInSample
Flag for presens of sampling in cluster.
valarray_t posNormInSample
Positive (absolute) normalization energy.
static void fill(valarray_t &array, double value=0.)
Pre-fill array with given value.