ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloConditions
src
CaloNoise.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CaloConditions/CaloNoise.h
"
6
#include "
CxxUtils/trapping_fp.h
"
7
#include "boost/multi_array.hpp"
8
#include "TMath.h"
9
#include <cmath>
10
11
CaloNoise::CaloNoise
(
const
size_t
nLArCells,
12
const
size_t
nLArGains,
13
const
size_t
nTileCells,
14
const
size_t
nTileGains,
15
const
CaloCell_Base_ID
* caloCellId,
16
const
NOISETYPE
noisetype)
17
:
m_caloCellId
(caloCellId)
18
,
m_noiseType
(noisetype)
19
{
20
21
boost::multi_array_types::extent_gen lar_extent_gen;
22
m_larNoise
.resize(lar_extent_gen[nLArGains][nLArCells]);
23
boost::multi_array_types::extent_gen tile_extent_gen;
24
m_tileNoise
.resize(tile_extent_gen[nTileGains][nTileCells]);
25
26
IdentifierHash
h1,h2;
27
m_caloCellId
->calo_cell_hash_range(
CaloCell_ID::TILE
, h1,h2);
28
m_tileHashOffset
=h1;
29
}
30
31
void
CaloNoise::setTileBlob
(std::unique_ptr<const CaloCondBlobFlt> flt,
const
float
lumi) {
32
m_tileBlob
=std::move(flt);
33
m_lumi
=lumi;
34
}
35
36
CaloNoise::~CaloNoise
() {
37
}
38
39
40
41
float
CaloNoise::calcSig
(
const
IdentifierHash
subHash,
const
int
dbGain,
const
float
e)
const
{
42
43
const
double
sigma1 =
m_tileBlob
->getData(subHash,dbGain,2);
44
const
double
sigma2 =
m_tileBlob
->getData(subHash,dbGain,3);
45
const
double
ratio =
m_tileBlob
->getData(subHash,dbGain,4);
46
47
48
if
((sigma1 == 0. && sigma2 == 0.) || e == 0.)
return
0.;
49
if
(sigma1 == 0.)
return
e/sigma2;
50
if
((ratio == 0.) || sigma2 == 0.)
return
e/sigma1;
51
const
double
x1 = e/sigma1;
52
const
double
x2 = e/sigma2;
53
54
constexpr
std::array<float,2> valid_range{0.9,7.5};
55
const
float
wide_gauss_sigma = std::min(std::abs(x1),std::abs(x2));
56
if
(wide_gauss_sigma > valid_range[1])
return
wide_gauss_sigma;
57
58
const
float
narrow_gauss_sigma= std::max(std::abs(x1),std::abs(x2));
59
if
(narrow_gauss_sigma < valid_range[0])
return
narrow_gauss_sigma;
60
61
62
const
double
y1= TMath::Erf(M_SQRT1_2*x1);
63
const
double
y2= TMath::Erf(M_SQRT1_2*x2);
64
65
const
double
z
= ( y1*sigma1 + ratio*y2*sigma2 )/( sigma1 + ratio*sigma2);
66
67
//return the C.L. probability (with sign!)
68
// return z;
69
70
// if instead you want to return the sigma-equivalent C.L.
71
// (with sign!) use the following line
72
return
M_SQRT2*TMath::ErfInverse(
z
);
73
}
74
75
76
float
CaloNoise::getTileEffSigma
(
const
IdentifierHash
subHash,
const
int
gain,
const
float
e)
const
{
77
// Tell clang to optimize assuming that FP exceptions can trap.
78
// Otherwise, it can vectorize the division, which can lead to
79
// spurious division-by-zero traps from unused vector lanes.
80
CXXUTILS_TRAPPING_FP
;
81
82
const
unsigned
int
dbGain =
CaloCondUtils::getDbCaloGain
(gain);
83
if
(!
m_tileBlob
) {
84
//No data (pilup-noise only): return cached noise
85
return
m_tileNoise
[dbGain][subHash];
86
}
87
88
const
float
sigma=
calcSig
(subHash,dbGain,e);
89
const
float
a
= (sigma != 0.) ? std::abs(e/sigma) : 0.0;
90
91
if
(
m_noiseType
==
CaloNoise::ELEC
) {
92
return
a
;
93
}
94
95
//Case: Total Noise
96
const
float
b=
m_tileBlob
->getData(subHash,dbGain,1);
97
const
int
objver =
m_tileBlob
->getObjVersion();
98
float
x
=0;
99
if
(objver==1){
100
//=== Total noise parameterized as
101
//=== Sigma**2 = a**2 + b**2 * Lumi
102
x
= std::sqrt(
a
*
a
+ b*b*
m_lumi
);
103
}
104
else
if
(objver==2) {
105
//== parameterization for pedestal = a + b*Lumi
106
x
=
a
+b*
m_lumi
;
107
}
108
else
{
109
throw
CaloCond::VersionConflict
(
"CaloNoise::get2dEffSigma "
,objver);
110
}
111
return
x
;
112
}
CaloNoise.h
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
x
#define x
z
#define z
CaloCell_Base_ID
Helper base class for offline cell identifiers.
Definition
CaloCell_Base_ID.h:40
CaloCell_Base_ID::TILE
@ TILE
Definition
CaloCell_Base_ID.h:45
CaloCondUtils::getDbCaloGain
static unsigned int getDbCaloGain(int caloGain)
Returns the non-negative gainId to be used with the COOL DB.
Definition
CaloCondUtils.cxx:86
CaloCond::VersionConflict
Thrown if object version in BLOB does not agree with class version.
Definition
Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:64
CaloNoise::calcSig
float calcSig(const IdentifierHash tilehash, const int gain, const float energy) const
Definition
CaloNoise.cxx:41
CaloNoise::m_tileNoise
boost::multi_array< float, 2 > m_tileNoise
Definition
CaloNoise.h:98
CaloNoise::m_caloCellId
const CaloCell_Base_ID * m_caloCellId
Definition
CaloNoise.h:94
CaloNoise::m_larNoise
boost::multi_array< float, 2 > m_larNoise
Definition
CaloNoise.h:97
CaloNoise::~CaloNoise
~CaloNoise()
Definition
CaloNoise.cxx:36
CaloNoise::m_tileHashOffset
unsigned m_tileHashOffset
Definition
CaloNoise.h:99
CaloNoise::m_lumi
float m_lumi
Definition
CaloNoise.h:104
CaloNoise::getTileEffSigma
float getTileEffSigma(const IdentifierHash subHash, const int gain, const float e) const
Definition
CaloNoise.cxx:76
CaloNoise::m_noiseType
NOISETYPE m_noiseType
Definition
CaloNoise.h:105
CaloNoise::m_tileBlob
std::unique_ptr< const CaloCondBlobFlt > m_tileBlob
Definition
CaloNoise.h:103
CaloNoise::CaloNoise
CaloNoise()=delete
CaloNoise::setTileBlob
void setTileBlob(std::unique_ptr< const CaloCondBlobFlt > flt, const float lumi)
Definition
CaloNoise.cxx:31
CaloNoise::NOISETYPE
NOISETYPE
Conditions Data Object holding the calorimeter noise per cell and per gain.
Definition
CaloNoise.h:22
CaloNoise::ELEC
@ ELEC
Definition
CaloNoise.h:22
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
trapping_fp.h
Tell the compiler to optimize assuming that FP may trap.
CXXUTILS_TRAPPING_FP
#define CXXUTILS_TRAPPING_FP
Definition
trapping_fp.h:24
Generated on
for ATLAS Offline Software by
1.17.0