ATLAS Offline Software
TileEMScaleCondAlg.cxx
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 /*
3  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 #include "TileEMScaleCondAlg.h"
10 
11 
14 
15 TileEMScaleCondAlg::TileEMScaleCondAlg(const std::string& name, ISvcLocator* pSvcLocator) :
16  AthAlgorithm(name, pSvcLocator),
17  m_useOflLasFib(false),
18  m_maxChannels(0),
19  m_maxGains(0),
20  m_onlCacheUnit(TileRawChannelUnit::Invalid)
21 {
22 }
23 
24 
25 
27 
28  ATH_MSG_DEBUG( "In initialize()" );
29 
30  //=== Configure online cache unit
31  if (m_onlCacheUnitString == "Invalid") {
33  } else if (m_onlCacheUnitString == "OnlineADCcounts") {
35  } else if (m_onlCacheUnitString == "OnlinePicoCoulombs") {
37  } else if (m_onlCacheUnitString == "OnlineCesiumPicoCoulombs") {
39  } else if (m_onlCacheUnitString == "OnlineMegaElectronVolts") {
41  } else {
42  ATH_MSG_WARNING( "Unrecoginzed jobOption OnlCacheUnit=" << m_onlCacheUnitString << ". "
43  << "Setting it to \"Invalid\"!" );
45  }
46 
47 
48  // Tile cabling service
49  ATH_CHECK( m_cablingSvc.retrieve() );
50 
51  ATH_CHECK( m_oflCisLinProxy.retrieve() );
52  ATH_CHECK( m_oflCisNlnProxy.retrieve() );
53 
54  ATH_CHECK( m_oflLasLinProxy.retrieve() );
55  ATH_CHECK( m_oflLasNlnProxy.retrieve() );
56 
57  m_useOflLasFib = !(m_oflLasFibProxy.empty());
58 
59  if (m_useOflLasFib) {
60  //=== retrieve offline proxy
61  CHECK( m_oflLasFibProxy.retrieve() );
62  ATH_MSG_INFO("ProxyOflLasFib is set up and can be used");
63  } else {
64  ATH_MSG_INFO("ProxyOflLasFib is not set up and cannot be used");
65  m_oflLasFibProxy.disable();
66  }
67 
68  ATH_CHECK( m_oflCesProxy.retrieve() );
69  ATH_CHECK( m_oflEmsProxy.retrieve() );
70 
72 
73  if (m_onlCisProxy.empty() || m_onlLasProxy.empty()
74  || m_onlCesProxy.empty() || m_onlEmsProxy.empty()) {
75 
76  ATH_MSG_ERROR( "Requested valid OnlCacheUnit (" << m_onlCacheUnitString << ") "
77  << "but at least one Onl{Cis|Las|Ces|Ems}Proxy is not set up!" );
78  return StatusCode::FAILURE;
79  }
80 
81  //=== Resize onlCache to desired size
82  const TileCablingService* cabling = m_cablingSvc->cablingService();
83  if (!cabling) {
84  ATH_MSG_ERROR( "Unable to retrieve TileCablingService" );
85  return StatusCode::FAILURE;
86  }
87 
88 
89  m_maxChannels = cabling->getMaxChannels();
90  m_maxGains = cabling->getMaxGains();
91 
92  } else {
93 
94  ATH_MSG_INFO( "Undoing online calibration is not requested, "
95  << "since OnlCacheUnit=" << m_onlCacheUnitString );
96  }
97 
98  if (m_onlCisProxy.empty()) {
99  ATH_MSG_INFO( "Loading of online CIS calibration constants is not requested" );
100 
101  m_onlCisProxy.disable();
102  } else {
103  ATH_CHECK( m_onlCisProxy.retrieve() );
104  }
105 
106  if (m_onlLasProxy.empty()) {
107  ATH_MSG_INFO( "Loading of online Laser calibration constants is not requested" );
108 
109  m_onlLasProxy.disable();
110  } else {
111  ATH_CHECK( m_onlLasProxy.retrieve() );
112  }
113 
114  if (m_onlCesProxy.empty()) {
115  ATH_MSG_INFO( "Loading of online Cesium calibration constants is not requested" );
116 
117  m_onlCesProxy.disable();
118  } else {
119  ATH_CHECK( m_onlCesProxy.retrieve() );
120  }
121 
122  if (m_onlEmsProxy.empty()) {
123  ATH_MSG_INFO( "Loading of online EM scale calibration constants is not requested" );
124 
125  m_onlEmsProxy.disable();
126  } else {
127  ATH_CHECK( m_onlEmsProxy.retrieve() );
128  }
129 
131 
132  return StatusCode::SUCCESS;
133 }
134 
135 
137 
139 
140  if (calibEms.isValid()) {
141  ATH_MSG_DEBUG("Found valid TileEMScale: " << calibEms.key());
142  return StatusCode::SUCCESS;
143  }
144 
145 
146  std::unique_ptr<TileEMScale> emsData = std::make_unique<TileEMScale>();
147 
148  emsData->setMaxChannels(m_maxChannels);
149  emsData->setMaxGains(m_maxGains);
151 
152 
153  // Get offline CIS linear calibration constants
154  EventIDRange oflCisLinRange;
155  std::unique_ptr<TileCalibDataFlt> calibOflCisLin = std::make_unique<TileCalibDataFlt>();
156 
157  ATH_CHECK( m_oflCisLinProxy->fillCalibData(*calibOflCisLin, oflCisLinRange) );
158  emsData->setCalibOflCisLin(std::move(calibOflCisLin));
159 
160  // Get offline CIS non-linear calibration constants
161  EventIDRange oflCisNlnRange;
162  std::unique_ptr<TileCalibDataFlt> calibOflCisNln = std::make_unique<TileCalibDataFlt>();
163 
164  ATH_CHECK( m_oflCisNlnProxy->fillCalibData(*calibOflCisNln, oflCisNlnRange) );
165  emsData->setCalibOflCisNln(std::move(calibOflCisNln));
166 
167 
168  // Get offline Laser linear calibration constants
169  EventIDRange oflLasLinRange;
170  std::unique_ptr<TileCalibDataFlt> calibOflLasLin = std::make_unique<TileCalibDataFlt>();
171 
172  ATH_CHECK( m_oflLasLinProxy->fillCalibData(*calibOflLasLin, oflLasLinRange) );
173  emsData->setCalibOflLasLin(std::move(calibOflLasLin));
174 
175 
176  // Get offline Laser non-linear calibration constants
177  EventIDRange oflLasNlnRange;
178  std::unique_ptr<TileCalibDataFlt> calibOflLasNln = std::make_unique<TileCalibDataFlt>();
179 
180  ATH_CHECK( m_oflLasNlnProxy->fillCalibData(*calibOflLasNln, oflLasNlnRange) );
181  emsData->setCalibOflLasNln(std::move(calibOflLasNln));
182 
183 
184  // Get offline Ces calibration constants
185  EventIDRange oflCesRange;
186  std::unique_ptr<TileCalibDataFlt> calibOflCes = std::make_unique<TileCalibDataFlt>();
187 
188  ATH_CHECK( m_oflCesProxy->fillCalibData(*calibOflCes, oflCesRange) );
189  emsData->setCalibOflCes(std::move(calibOflCes));
190 
191 
192  // Get offline Ems calibration constants
193  EventIDRange oflEmsRange;
194  std::unique_ptr<TileCalibDataFlt> calibOflEms = std::make_unique<TileCalibDataFlt>();
195 
196  ATH_CHECK( m_oflEmsProxy->fillCalibData(*calibOflEms, oflEmsRange) );
197  emsData->setCalibOflEms(std::move(calibOflEms));
198 
199 
200  EventIDRange eventRange = EventIDRange::intersect(oflCisLinRange, oflCisNlnRange,
201  oflLasLinRange, oflLasNlnRange,
202  oflCesRange, oflEmsRange);
203 
204 
205  if (m_useOflLasFib) {
206  // Get offline Laser fiber calibration constants
207  EventIDRange oflLasFibRange;
208  std::unique_ptr<TileCalibDataFlt> calibOflLasFib = std::make_unique<TileCalibDataFlt>();
209 
210  ATH_CHECK( m_oflLasFibProxy->fillCalibData(*calibOflLasFib, oflLasFibRange) );
211  emsData->setCalibOflLasFib(std::move(calibOflLasFib));
212 
213  eventRange = EventIDRange::intersect(eventRange, oflLasFibRange);
214  }
215 
216  if (!m_onlCisProxy.empty()) {
217  // Get online CIS calibration constants
218  EventIDRange onlCisRange;
219  std::unique_ptr<TileCalibDataFlt> calibOnlCis = std::make_unique<TileCalibDataFlt>();
220 
221  ATH_CHECK( m_onlCisProxy->fillCalibData(*calibOnlCis, onlCisRange) );
222  emsData->setCalibOnlCis(std::move(calibOnlCis));
223 
224  eventRange = EventIDRange::intersect(eventRange, onlCisRange);
225  }
226 
227  if (!m_onlLasProxy.empty()) {
228  // Get online Laser calibration constants
229  EventIDRange onlLasRange;
230  std::unique_ptr<TileCalibDataFlt> calibOnlLas = std::make_unique<TileCalibDataFlt>();
231 
232  ATH_CHECK( m_onlLasProxy->fillCalibData(*calibOnlLas, onlLasRange) );
233  emsData->setCalibOnlLas(std::move(calibOnlLas));
234 
235  eventRange = EventIDRange::intersect(eventRange, onlLasRange);
236  }
237 
238  if (!m_onlCesProxy.empty()) {
239  // Get online Ces calibration constants
240  EventIDRange onlCesRange;
241  std::unique_ptr<TileCalibDataFlt> calibOnlCes = std::make_unique<TileCalibDataFlt>();
242 
243  ATH_CHECK( m_onlCesProxy->fillCalibData(*calibOnlCes, onlCesRange) );
244  emsData->setCalibOnlCes(std::move(calibOnlCes));
245 
246  eventRange = EventIDRange::intersect(eventRange, onlCesRange);
247  }
248 
249  if (!m_onlEmsProxy.empty()) {
250  // Get online Ems calibration constants
251  EventIDRange onlEmsRange;
252  std::unique_ptr<TileCalibDataFlt> calibOnlEms = std::make_unique<TileCalibDataFlt>();
253 
254  ATH_CHECK( m_onlEmsProxy->fillCalibData(*calibOnlEms, onlEmsRange) );
255  emsData->setCalibOnlEms(std::move(calibOnlEms));
256 
257  eventRange = EventIDRange::intersect(eventRange, onlEmsRange);
258  }
259 
260 
261  if(eventRange.start() > eventRange.stop()) {
262  ATH_MSG_ERROR("Invalid intersection range: " << eventRange);
263  return StatusCode::FAILURE;
264  }
265 
266  if (emsData->initialize()) {
267  ATH_MSG_DEBUG("TileEMScale object is initialized successfully.");
268  } else {
269  ATH_MSG_ERROR("Impossible to inizialize TileEMScale object!");
270  return StatusCode::FAILURE;
271  }
272 
273  if(calibEms.record(eventRange, emsData.release()).isFailure()) {
274  ATH_MSG_ERROR("Could not record TileEMScale object with "
275  << calibEms.key()
276  << " with EventRange " << eventRange
277  << " into Conditions Store");
278  return StatusCode::FAILURE;
279  } else {
280 
281  ATH_MSG_VERBOSE("Recorded TileEMScale object with "
282  << calibEms.key()
283  << " with EventRange " << eventRange
284  << " into Conditions Store");
285  }
286 
287  return StatusCode::SUCCESS;
288 
289 }
290 
291 
293  return StatusCode::SUCCESS;
294 }
TileEMScale::setCalibOnlLas
void setCalibOnlLas(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:441
TileRawChannelUnit
Definition: TileRawChannelUnit.h:13
TileEMScaleCondAlg::m_oflCisNlnProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_oflCisNlnProxy
Tool to get offline non-linear CIS calibration constants.
Definition: TileEMScaleCondAlg.h:52
TileEMScaleCondAlg::m_oflLasNlnProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_oflLasNlnProxy
Tool to get non-linear Laser corection factors.
Definition: TileEMScaleCondAlg.h:64
TileEMScale::setCalibOnlEms
void setCalibOnlEms(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:449
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TileEMScaleCondAlg::m_oflLasLinProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_oflLasLinProxy
Tool to get offline linear Laser correction factors.
Definition: TileEMScaleCondAlg.h:58
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
TileEMScale::setCalibOflCes
void setCalibOflCes(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:428
TileEMScaleCondAlg::m_calibEmsKey
SG::WriteCondHandleKey< TileEMScale > m_calibEmsKey
Name of output TileEMScale.
Definition: TileEMScaleCondAlg.h:115
TileEMScaleCondAlg::m_onlEmsProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_onlEmsProxy
Tool to get Tile online EMS factors.
Definition: TileEMScaleCondAlg.h:108
TileEMScale::setOnlineCacheUnit
void setOnlineCacheUnit(TileRawChannelUnit::UNIT onlCacheUnit)
Set online cache unit.
Definition: TileEMScale.h:445
TileCalibUtils.h
TileEMScaleCondAlg::m_useOflLasFib
bool m_useOflLasFib
Definition: TileEMScaleCondAlg.h:125
TileRawChannelUnit::OnlineADCcounts
@ OnlineADCcounts
Definition: TileRawChannelUnit.h:21
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TileEMScale::setMaxChannels
void setMaxChannels(unsigned int maxChannels)
Definition: TileEMScale.h:450
TileEMScale::setCalibOflCisNln
void setCalibOflCisNln(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:412
ReadCondHandle.h
TileEMScale::setMaxGains
void setMaxGains(unsigned int maxGains)
Definition: TileEMScale.h:455
TileEMScaleCondAlg::finalize
virtual StatusCode finalize() override
Definition: TileEMScaleCondAlg.cxx:292
TileEMScaleCondAlg::m_cablingSvc
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
Definition: TileEMScaleCondAlg.h:121
TileRawChannelUnit::OnlinePicoCoulombs
@ OnlinePicoCoulombs
Definition: TileRawChannelUnit.h:22
TileEMScaleCondAlg::initialize
virtual StatusCode initialize() override
Definition: TileEMScaleCondAlg.cxx:26
TileEMScaleCondAlg::m_maxGains
unsigned int m_maxGains
Definition: TileEMScaleCondAlg.h:127
TileEMScale::setCalibOnlCis
void setCalibOnlCis(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:437
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileEMScaleCondAlg::m_maxChannels
unsigned int m_maxChannels
Definition: TileEMScaleCondAlg.h:126
TileCablingService.h
TileEMScaleCondAlg::execute
virtual StatusCode execute() override
Definition: TileEMScaleCondAlg.cxx:136
TileRawChannelUnit::OnlineCesiumPicoCoulombs
@ OnlineCesiumPicoCoulombs
Definition: TileRawChannelUnit.h:23
TileEMScaleCondAlg::m_onlLasProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_onlLasProxy
Tool to get Tile online Laser correction factors.
Definition: TileEMScaleCondAlg.h:96
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
WriteCondHandle.h
TileRawChannelUnit::Invalid
@ Invalid
Definition: TileRawChannelUnit.h:26
TileEMScale::setCalibOflLasLin
void setCalibOflLasLin(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:416
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TileCablingService
Definition: TileCablingService.h:23
AthAlgorithm
Definition: AthAlgorithm.h:47
TileEMScaleCondAlg::m_oflCesProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_oflCesProxy
Tool to get offline Cesium calibration constants.
Definition: TileEMScaleCondAlg.h:76
TileEMScaleCondAlg.h
TileEMScale::setCalibOnlCes
void setCalibOnlCes(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:445
TileEMScaleCondAlg::m_oflLasFibProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_oflLasFibProxy
Tool to get offline Laser fiber correction factors.
Definition: TileEMScaleCondAlg.h:70
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TileEMScaleCondAlg::m_oflCisLinProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_oflCisLinProxy
Tool to get offline CIS calibration constants.
Definition: TileEMScaleCondAlg.h:46
TileEMScale::setCalibOflEms
void setCalibOflEms(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:432
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TileEMScale::setCalibOflCisLin
void setCalibOflCisLin(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:408
TileRawChannelUnit.h
TileEMScaleCondAlg::m_onlCisProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_onlCisProxy
Tool to get online CIS calibration constants.
Definition: TileEMScaleCondAlg.h:90
TileEMScale::setCalibOflLasFib
void setCalibOflLasFib(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:424
Amg::intersect
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point of closest approach of two lines.
Definition: GeoPrimitivesHelpers.h:325
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TileEMScaleCondAlg::m_oflEmsProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_oflEmsProxy
Tool to get offline EMS factors.
Definition: TileEMScaleCondAlg.h:82
TileEMScale::initialize
bool initialize()
Definition: TileEMScale.cxx:35
TileEMScaleCondAlg::m_onlCacheUnitString
Gaudi::Property< std::string > m_onlCacheUnitString
Online cache units as string, see TileIdentifier/TileRawChannelUnit.h.
Definition: TileEMScaleCondAlg.h:40
TileEMScaleCondAlg::m_onlCacheUnit
TileRawChannelUnit::UNIT m_onlCacheUnit
Definition: TileEMScaleCondAlg.h:128
TileEMScaleCondAlg::TileEMScaleCondAlg
TileEMScaleCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TileEMScaleCondAlg.cxx:15
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
TileEMScale::setCalibOflLasNln
void setCalibOflLasNln(std::unique_ptr< TileCalibDataFlt > calibData)
Definition: TileEMScale.cxx:420
TileEMScaleCondAlg::m_onlCesProxy
ToolHandle< ITileCondProxy< TileCalibDrawerFlt > > m_onlCesProxy
Tool to get Tile online Cesium calibration constants.
Definition: TileEMScaleCondAlg.h:102
TileRawChannelUnit::OnlineMegaElectronVolts
@ OnlineMegaElectronVolts
Definition: TileRawChannelUnit.h:24