ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileConditions
src
TileCondToolTMDB.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
// Tile includes
7
#include "
TileConditions/TileCondToolTMDB.h
"
8
#include "
TileCalibBlobObjs/TileCalibDrawerFlt.h
"
9
#include "
TileCalibBlobObjs/TileCalibUtils.h
"
10
11
// Athena includes
12
#include "
AthenaKernel/errorcheck.h
"
13
#include "
StoreGate/ReadCondHandle.h
"
14
15
16
//
17
//____________________________________________________________________
18
TileCondToolTMDB::TileCondToolTMDB
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent)
19
:
AthAlgTool
(
type
, name, parent)
20
{
21
declareInterface<ITileCondToolTMDB>(
this
);
22
declareInterface<TileCondToolTMDB>(
this
);
23
}
24
25
//
26
//____________________________________________________________________
27
TileCondToolTMDB::~TileCondToolTMDB
() {
28
}
29
30
//
31
//____________________________________________________________________
32
StatusCode
TileCondToolTMDB::initialize
() {
33
34
ATH_MSG_DEBUG
(
"In initialize()"
);
35
36
//=== retrieve proxy
37
ATH_CHECK
(
m_calibThresholdKey
.initialize() );
38
ATH_CHECK
(
m_calibDelayKey
.initialize() );
39
ATH_CHECK
(
m_calibTmfKey
.initialize() );
40
ATH_CHECK
(
m_calibDataKey
.initialize() );
41
42
return
StatusCode::SUCCESS;
43
}
44
45
//
46
//____________________________________________________________________
47
StatusCode
TileCondToolTMDB::finalize
() {
48
49
ATH_MSG_DEBUG
(
"finalize called"
);
50
51
return
StatusCode::SUCCESS;
52
}
53
54
55
//
56
//____________________________________________________________________
57
float
TileCondToolTMDB::getThreshold
(
unsigned
int
drawerIdx,
unsigned
int
threshold
)
const
{
58
59
SG::ReadCondHandle<TileCalibData<TileCalibDrawerFlt>
> calibThreshold(
m_calibThresholdKey
);
60
return
calibThreshold->getCalibDrawer(drawerIdx)->getData(
threshold
, 0, 0);
61
62
}
63
64
65
//
66
//____________________________________________________________________
67
float
TileCondToolTMDB::getDelay
(
unsigned
int
drawerIdx,
unsigned
int
channel)
const
{
68
69
SG::ReadCondHandle<TileCalibData<TileCalibDrawerFlt>
> calibDelay(
m_calibDelayKey
);
70
return
calibDelay->getCalibDrawer(drawerIdx)->getData(channel, 0, 0);
71
72
}
73
74
//
75
//____________________________________________________________________
76
void
TileCondToolTMDB::getCalib
(
unsigned
int
drawerIdx,
unsigned
int
channel,
float
&
a
,
float
& b)
const
{
77
78
SG::ReadCondHandle<TileCalibData<TileCalibDrawerFlt>
> calibData(
m_calibDataKey
);
79
a
= calibData->getCalibDrawer(drawerIdx)->getData(channel, 0, 0);
80
b = calibData->getCalibDrawer(drawerIdx)->getData(channel, 0, 1);
81
82
}
83
84
85
//
86
//____________________________________________________________________
87
unsigned
int
TileCondToolTMDB::getWeights
(
unsigned
int
drawerIdx,
unsigned
int
channel,
TMDB::Weights
&
weights
)
const
{
88
89
SG::ReadCondHandle<TileCalibData<TileCalibDrawerFlt>
> calibTMF(
m_calibTmfKey
);
90
unsigned
int
nWeights = calibTMF->getCalibDrawer(drawerIdx)->getObjSizeUint32();
91
92
if
(
weights
.size() < nWeights ) {
93
ATH_MSG_ERROR
(
"Not enough space in output array to put all weights from DB (nothing to be done!): "
94
<<
weights
.size() <<
" < "
<< nWeights);
95
return
0;
96
}
97
98
for
(
unsigned
int
iWeight = 0; iWeight < nWeights; ++iWeight) {
99
weights
[iWeight] = calibTMF->getCalibDrawer(drawerIdx)->getData(channel, 0, iWeight);
100
}
101
102
return
nWeights;
103
}
104
105
106
107
108
//
109
//____________________________________________________________________
110
float
TileCondToolTMDB::channelCalib
(
unsigned
int
drawerIdx,
unsigned
int
channel,
float
amplitude)
const
{
111
112
SG::ReadCondHandle<TileCalibData<TileCalibDrawerFlt>
> calibData(
m_calibDataKey
);
113
return
amplitude * calibData->getCalibDrawer(drawerIdx)->getData(channel, 0, 0)
114
+ calibData->getCalibDrawer(drawerIdx)->getData(channel, 0, 1);
115
116
}
117
118
119
//
120
//____________________________________________________________________
121
float
TileCondToolTMDB::channelCalib
(
unsigned
int
drawerIdx,
unsigned
int
channel,
const
std::vector<float>& samples)
const
{
122
123
SG::ReadCondHandle<TileCalibData<TileCalibDrawerFlt>
> calibTMF(
m_calibTmfKey
);
124
125
if
(samples.size() != calibTMF->getCalibDrawer(drawerIdx)->getObjSizeUint32()) {
126
ATH_MSG_ERROR
(
"Number of samples and weights in DB are not compatible (nothing to be done!): "
127
<< samples.size() <<
" =! "
<< calibTMF->getCalibDrawer(drawerIdx)->getObjSizeUint32());
128
return
0;
129
}
130
131
float
amplitude(0.0F);
132
unsigned
int
iWeight(0);
133
for
(
float
sample : samples) {
134
amplitude += sample * calibTMF->getCalibDrawer(drawerIdx)->getData(channel, 0, iWeight);
135
++iWeight;
136
}
137
138
return
channelCalib
(drawerIdx, channel, amplitude);
139
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
errorcheck.h
Helpers for checking error return status codes and reporting errors.
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
ReadCondHandle.h
TileCalibDrawerFlt.h
TileCalibUtils.h
TileCondToolTMDB.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
TileCondToolTMDB::m_calibDelayKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibDelayKey
Definition
TileCondToolTMDB.h:45
TileCondToolTMDB::m_calibTmfKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibTmfKey
Definition
TileCondToolTMDB.h:48
TileCondToolTMDB::initialize
virtual StatusCode initialize() override
Definition
TileCondToolTMDB.cxx:32
TileCondToolTMDB::getThreshold
virtual float getThreshold(unsigned int drawerIdx, unsigned int threshold) const override
Definition
TileCondToolTMDB.cxx:57
TileCondToolTMDB::getDelay
virtual float getDelay(unsigned int drawerIdx, unsigned int channel) const override
Definition
TileCondToolTMDB.cxx:67
TileCondToolTMDB::getWeights
virtual unsigned int getWeights(unsigned int drawerIdx, unsigned int channel, TMDB::Weights &weights) const override
Definition
TileCondToolTMDB.cxx:87
TileCondToolTMDB::m_calibDataKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibDataKey
Definition
TileCondToolTMDB.h:51
TileCondToolTMDB::finalize
virtual StatusCode finalize() override
Definition
TileCondToolTMDB.cxx:47
TileCondToolTMDB::TileCondToolTMDB
TileCondToolTMDB(const std::string &type, const std::string &name, const IInterface *parent)
Definition
TileCondToolTMDB.cxx:18
TileCondToolTMDB::~TileCondToolTMDB
virtual ~TileCondToolTMDB()
Definition
TileCondToolTMDB.cxx:27
TileCondToolTMDB::getCalib
virtual void getCalib(unsigned int drawerIdx, unsigned int channel, float &a, float &b) const override
Definition
TileCondToolTMDB.cxx:76
TileCondToolTMDB::m_calibThresholdKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibThresholdKey
Definition
TileCondToolTMDB.h:42
TileCondToolTMDB::channelCalib
virtual float channelCalib(unsigned int drawerIdx, unsigned int channel, const std::vector< float > &samples) const override
Definition
TileCondToolTMDB.cxx:121
TMDB::Weights
std::array< float, 7 > Weights
Definition
ITileCondToolTMDB.h:14
type
threshold
Definition
chainparser.cxx:74
weights
Definition
herwig7_interface.h:38
Generated on
for ATLAS Offline Software by
1.17.0