ATLAS Offline Software
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 //____________________________________________________________________
18 TileCondToolTMDB::TileCondToolTMDB(const std::string& type, const std::string& name, const IInterface* parent)
20 {
21  declareInterface<ITileCondToolTMDB>(this);
22  declareInterface<TileCondToolTMDB>(this);
23 }
24 
25 //
26 //____________________________________________________________________
28 }
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 //____________________________________________________________________
57 float 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 //____________________________________________________________________
67 float TileCondToolTMDB::getDelay(unsigned int drawerIdx, unsigned int channel) const {
68 
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 
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 
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 
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 
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 }
TMDB::Weights
std::array< float, 7 > Weights
Definition: ITileCondToolTMDB.h:14
TileCalibDrawerFlt.h
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
TileCondToolTMDB::getDelay
virtual float getDelay(unsigned int drawerIdx, unsigned int channel) const override
Definition: TileCondToolTMDB.cxx:67
TileCondToolTMDB::TileCondToolTMDB
TileCondToolTMDB(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TileCondToolTMDB.cxx:18
TileCalibUtils.h
TileCondToolTMDB::getCalib
virtual void getCalib(unsigned int drawerIdx, unsigned int channel, float &a, float &b) const override
Definition: TileCondToolTMDB.cxx:76
TileCondToolTMDB.h
ReadCondHandle.h
TileCondToolTMDB::channelCalib
virtual float channelCalib(unsigned int drawerIdx, unsigned int channel, const std::vector< float > &samples) const override
Definition: TileCondToolTMDB.cxx:121
TileCondToolTMDB::getThreshold
virtual float getThreshold(unsigned int drawerIdx, unsigned int threshold) const override
Definition: TileCondToolTMDB.cxx:57
TileCondToolTMDB::~TileCondToolTMDB
virtual ~TileCondToolTMDB()
Definition: TileCondToolTMDB.cxx:27
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
TileCondToolTMDB::m_calibDelayKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibDelayKey
Definition: TileCondToolTMDB.h:45
TileCondToolTMDB::m_calibDataKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibDataKey
Definition: TileCondToolTMDB.h:51
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
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
TileCondToolTMDB::m_calibThresholdKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibThresholdKey
Definition: TileCondToolTMDB.h:42
TileCondToolTMDB::m_calibTmfKey
SG::ReadCondHandleKey< TileCalibDataFlt > m_calibTmfKey
Definition: TileCondToolTMDB.h:48
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileCondToolTMDB::getWeights
virtual unsigned int getWeights(unsigned int drawerIdx, unsigned int channel, TMDB::Weights &weights) const override
Definition: TileCondToolTMDB.cxx:87
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
errorcheck.h
Helpers for checking error return status codes and reporting errors.
threshold
Definition: chainparser.cxx:74
TileCondToolTMDB::initialize
virtual StatusCode initialize() override
Definition: TileCondToolTMDB.cxx:32
a
TList * a
Definition: liststreamerinfos.cxx:10
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
F
#define F(x, y, z)
Definition: MD5.cxx:112
AthAlgTool
Definition: AthAlgTool.h:26
TileCondToolTMDB::finalize
virtual StatusCode finalize() override
Definition: TileCondToolTMDB.cxx:47