ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11// Athena includes
14
15
16//
17//____________________________________________________________________
18TileCondToolTMDB::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//____________________________________________________________________
29
30//
31//____________________________________________________________________
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//____________________________________________________________________
48
49 ATH_MSG_DEBUG( "finalize called" );
50
51 return StatusCode::SUCCESS;
52}
53
54
55//
56//____________________________________________________________________
57float TileCondToolTMDB::getThreshold(unsigned int drawerIdx, unsigned int threshold) const {
58
60 return calibThreshold->getCalibDrawer(drawerIdx)->getData(threshold, 0, 0);
61
62}
63
64
65//
66//____________________________________________________________________
67float TileCondToolTMDB::getDelay(unsigned int drawerIdx, unsigned int channel) const {
68
70 return calibDelay->getCalibDrawer(drawerIdx)->getData(channel, 0, 0);
71
72}
73
74//
75//____________________________________________________________________
76void TileCondToolTMDB::getCalib(unsigned int drawerIdx, unsigned int channel, float& a, float& b) const {
77
79 a = calibData->getCalibDrawer(drawerIdx)->getData(channel, 0, 0);
80 b = calibData->getCalibDrawer(drawerIdx)->getData(channel, 0, 1);
81
82}
83
84
85//
86//____________________________________________________________________
87unsigned int TileCondToolTMDB::getWeights(unsigned int drawerIdx, unsigned int channel, TMDB::Weights& weights) const {
88
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//____________________________________________________________________
110float TileCondToolTMDB::channelCalib(unsigned int drawerIdx, unsigned int channel, float amplitude) const {
111
113 return amplitude * calibData->getCalibDrawer(drawerIdx)->getData(channel, 0, 0)
114 + calibData->getCalibDrawer(drawerIdx)->getData(channel, 0, 1);
115
116}
117
118
119//
120//____________________________________________________________________
121float TileCondToolTMDB::channelCalib(unsigned int drawerIdx, unsigned int channel, const std::vector<float>& samples) const {
122
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
static Double_t a
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibDelayKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibTmfKey
virtual StatusCode initialize() override
virtual float getThreshold(unsigned int drawerIdx, unsigned int threshold) const override
virtual float getDelay(unsigned int drawerIdx, unsigned int channel) const override
virtual unsigned int getWeights(unsigned int drawerIdx, unsigned int channel, TMDB::Weights &weights) const override
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibDataKey
virtual StatusCode finalize() override
TileCondToolTMDB(const std::string &type, const std::string &name, const IInterface *parent)
virtual void getCalib(unsigned int drawerIdx, unsigned int channel, float &a, float &b) const override
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibThresholdKey
virtual float channelCalib(unsigned int drawerIdx, unsigned int channel, const std::vector< float > &samples) const override
std::array< float, 7 > Weights