17#include "CoralBase/Attribute.h"
55 return StatusCode::FAILURE;
62 unsigned int ros = roses[moduleType];
63 unsigned int channel = 0;
66 int pmt =
m_cabling->channel2hole(ros, channel);
79 for (; channel < 68; ++channel) {
107 return StatusCode::SUCCESS;
117 return StatusCode::SUCCESS;
120 std::unique_ptr<TileDCSState> dcsStateData = std::make_unique<TileDCSState>();
132 const std::pair<int, int> rosDrawerPair =
m_rosDrawerHV.at(coolChannel);
133 unsigned int ros = rosDrawerPair.first;
134 unsigned int drawer = rosDrawerPair.second;
137 <<
", drawer: " << drawer
138 <<
", COOL channel: " << coolChannel
139 <<
", payload: " << chanAttrListPair.second);
143 for (
const coral::Attribute& attribute : chanAttrListPair.second) {
145 dcsStateData->setChannelHV(ros, drawer, channel, attribute.data<
float>());
163 unsigned int ros = rosDrawerPair.first;
164 unsigned int drawer = rosDrawerPair.second;
167 <<
", drawer: " << drawer
168 <<
", COOL channel: " << coolChannel
169 <<
", payload: " << chanAttrListPair.second);
173 for (
const coral::Attribute& attribute : chanAttrListPair.second) {
175 dcsStateData->setChannelHVSet(ros, drawer, channel, attribute.data<
float>());
176 ATH_MSG_VERBOSE(
"HVSET[" << pmt0 <<
"] = " << attribute.data<
float>() );
196 unsigned int ros = rosDrawerPair.first;
197 unsigned int drawer = rosDrawerPair.second;
200 <<
", drawer: " << drawer
201 <<
", COOL channel: " << coolChannel
202 <<
", payload: " << chanAttrListPair.second);
204 for (
const coral::Attribute& attribute : chanAttrListPair.second) {
205 dcsStateData->setDrawerStates(ros, drawer, attribute.data<
int>());
219 int specialModuleType(moduleType);
221 if ((ros == 3 && drawer == 14) || (ros == 4 && drawer == 17)) {
223 }
else if (!
m_cabling->C10_connected(drawer)) {
233 float hvSet(dcsStateData->getChannelHVSet(ros, drawer, channel));
234 float hv(dcsStateData->getChannelHV(ros, drawer, channel));
237 if (hvSet >= 1.0 && hv >= 0.0
238 && hvSet < 999.9 && hv < 999.9) {
246 std::fabs(hvSet + itr->second.second - hv) : std::fabs(hvSet - hv);
252 float hvGap = std::fabs(hvSet - hv);
260 dcsStateData->setDCSHVStatus(ros, drawer, channel, channelHVStatus);
263 dcsStateData->setDCSStatus(ros, drawer, channel, drawerStatus);
265 dcsStateData->setDCSStatus(ros, drawer, channel, std::max(drawerStatus, channelHVStatus));
275 if (
msgLvl(MSG::VERBOSE)) {
277 <<
" Status = " << drawerStatus <<
endmsg;
285 <<
" channel = " << channel
286 <<
" pmt = " << pmt0 + 1
287 <<
" HV = " << dcsStateData->getChannelHV(ros, drawer, channel)
288 <<
" HVSET = " << dcsStateData->getChannelHVSet(ros, drawer, channel)
289 <<
" Status = " << status
298 if(dcsState.
record(std::move(dcsStateData)).isFailure()) {
302 <<
" with EventRange " << dcsState.
getRange()
303 <<
" into Conditions Store");
305 return StatusCode::FAILURE;
310 <<
" with EventRange " << dcsState.
getRange()
311 <<
" into Conditions Store");
314 return StatusCode::SUCCESS;
322 const std::string& subStr,
323 std::vector<std::pair<int, int>>& rosDrawer) {
326 std::ifstream
file(fullFileName.c_str());
327 if (!
file.is_open()) {
334 rosDrawer.resize(257, std::make_pair<int, int>(0xFFFF, 0xFFFF));
336 std::string compName[5] = {
"XXX",
"ATLTILLV01",
"ATLTILLV02",
"ATLTILLV00",
"ATLTILLV03" };
338 unsigned int ind, ros, module;
344 file >> s >> ind >> line;
346 if (
file.eof() ||
file.fail())
break;
347 if (ind > 1000000)
break;
350 pos = line.find(compName[ros]);
351 if (pos != std::string::npos)
break;
355 msg(MSG::WARNING) <<
"File " << fileName <<
" Wrong computer name in " << line <<
endmsg;
359 pos = line.find(subStr);
360 if (pos == std::string::npos) {
361 ATH_MSG_WARNING(
"File " << fileName <<
" Word " << subStr <<
" not found in " << line);
365 module = atoi(&line[pos + subStr.size()]);
367 ATH_MSG_WARNING(
"File " << fileName <<
" Wrong module number in " << line);
373 if (rosDrawer.size() <= ind) {
374 rosDrawer.resize(ind + 1, std::make_pair<int, int> (0xFFFF, 0xFFFF));
377 rosDrawer[ind] = std::make_pair<int, int>(ros, (module - 1));
390 std::ifstream
file(fullFileName.c_str());
391 if (!
file.is_open()) {
398 std::string partName[5] = {
"AUX",
"LBA",
"LBC",
"EBA",
"EBC" };
400 unsigned int ros, module, pmt;
408 file.getline(ll,
sizeof(ll));
410 if (
file.eof() ||
file.fail())
break;
412 line = std::string(ll);
415 pos = line.find(partName[ros]);
416 if (pos != std::string::npos)
break;
419 ATH_MSG_WARNING(
"File " << fileName <<
" Partition name not found in " << line);
423 module = atoi(&line[pos + 3]);
425 ATH_MSG_WARNING(
"File " << fileName <<
" Wrong module number in " << line);
429 pos = line.find(
"PMT number");
430 if (pos == std::string::npos) {
431 ATH_MSG_WARNING(
"File " << fileName <<
" Word 'PMT number' not found in " << line);
435 pmt = atoi(&line[pos + 10]);
437 ATH_MSG_WARNING(
"File " << fileName <<
" Wrong pmt number in " << line);
441 pos = line.find(
"Step Value is");
442 if (pos == std::string::npos) {
443 ATH_MSG_WARNING(
"File " << fileName <<
" Word 'Step Value is' not found in " << line);
447 delta = atof(&line[pos + 13]);
448 if (delta <= 0.0 || delta > 1000.0) {
449 ATH_MSG_WARNING(
"File " << fileName <<
" Wrong delta number in " << line);
453 pos = line.find(
"Offset is:");
454 if (pos == std::string::npos) {
455 ATH_MSG_WARNING(
"File " << fileName <<
" Word 'Offset is:' not found in " << line);
459 offset = atof(&line[pos + 10]);
460 if (offset < -1000.0 || offset > 1000.0) {
461 ATH_MSG_WARNING(
"File " << fileName <<
" Wrong offset number in " << line);
467 <<
" delta = " << delta
468 <<
" offset = " << offset);
483 const EventContext& ctx)
const {
486 wh.addDependency(emScale);
488 float laserReferenceHV = -5.;
489 float cesReferenceHV = -5.;
500 cesReferenceHV = emScale->getCesiumReferenceHV(drawerIdx, channel);
501 laserReferenceHV = emScale->getLaserReferenceHV(drawerIdx, channel);
503 if (laserReferenceHV >= 0.) {
509 if (
msgLvl(MSG::VERBOSE)) {
511 <<
" channel = " << channel
512 <<
" pmt = " << pmt0 + 1
515 if (laserReferenceHV >= 0.) {
516 msg(MSG::VERBOSE) <<
" Taken from Laser run (replace "
517 << cesReferenceHV <<
" cesium value)" <<
endmsg;
526 return StatusCode::SUCCESS;
531 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool msgLvl(const MSG::Level lvl) const
Base class for conditions algorithms.
ChanAttrListMap::value_type ChanAttrListPair
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
static const unsigned int MAX_ROS
Number of ROSs.
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
static const unsigned int MAX_DRAWER
Number of drawers in ROS 1-4.
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
static const unsigned int MAX_CHAN
Number of channels in drawer.
unsigned int getChannelKey(unsigned int ros, unsigned int drawer, unsigned int channel) const
@ brief Return Tile channel key used as index in internal caches @ ros Tile ROS in range [1....
Gaudi::Property< std::string > m_dcsChHvInCool
File name with mapping Tile DCS HV DB COOL channels to ROS and drawer.
bool m_isChannelUsed[4][NUMBER_OF_CHANNELS]
std::map< int, std::pair< float, float > > m_knownBadHV
Gaudi::Property< std::string > m_dcsChHvSetInCool
File name with mapping Tile DCS HVSET DB COOL channels to ROS and drawer.
int readBadHV(const std::string &fileName)
Read special deltas for few unstable PMTs.
SG::WriteCondHandleKey< TileDCSState > m_dcsStateKey
The name of TileDCSState object to produce and put into condition store.
Gaudi::Property< std::string > m_dcsChStatesInCool
File name with mapping Tile DCS STATES DB COOL channels to ROS and drawer.
std::vector< std::pair< int, int > > m_rosDrawerHV
int m_pmt2channel[2][NUMBER_OF_HVSET_CHANNELS]
Gaudi::Property< float > m_goodHVLimit
Tile DCS Status is OK if difference between measured and requested HV is below this limit.
Gaudi::Property< bool > m_readHVSet
Flag to control reading Tile DCS HVSET folder from DB.
std::vector< std::pair< int, int > > m_rosDrawerStates
virtual StatusCode initialize() override
Gaudi::Property< float > m_warningHVLimit
Mask channels with difference between measured and requested HV above this limit.
SG::ReadCondHandleKey< CondAttrListCollection > m_hvSetKey
The Tile DCS HVSET COOL folder name.
Gaudi::Property< std::vector< int > > m_warningDrawer
Status is WARNING if Tile DCS drawer states is like this.
Gaudi::Property< int > m_goodDrawer
Status is OK if Tile DCS drawer states is like this.
TileDCSCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< CondAttrListCollection > m_hvKey
The Tile DCS HV COOL folder name.
const TileCablingService * m_cabling
@ EXTENDED_BARREL_SPECIAL_C10
virtual StatusCode execute(const EventContext &ctx) const override
int m_channel2pmt[2][NUMBER_OF_HVSET_CHANNELS]
Gaudi::Property< bool > m_readHV
Flag to control reading Tile DCS HV folder from DB.
SG::ReadCondHandleKey< CondAttrListCollection > m_statesKey
The Tile DCS STATES COOL folder name.
std::vector< std::pair< int, int > > m_rosDrawerHVSet
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
Gaudi::Property< bool > m_readStates
Flag to control reading Tile DCS STATES folder from DB.
virtual StatusCode finalize() override
int readConfig(const std::string &fileName, const std::string &subStr, std::vector< std::pair< int, int > > &rosDrawer)
Read mapping of DB COOL channels into Tile ROS and drawer pairs.
StatusCode fillReferenceHV(TileDCSState &dcsState, SG::WriteCondHandle< TileDCSState > &wh, const EventContext &ctx) const
Store reference HV from Tile CES or Laser DB folder in TileDCSState.
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
The name of TileEMScale object to get reference HV from Cesium or Laser folder.
Condition object to keep Tile DCS status from DB.
float getChannelHVSet(unsigned int ros, unsigned int drawer, unsigned int channel) const
Return requested HV reported by DCS for given Tile channel.
TileDCSStatus
Describes Tile DCS status.
void setChannelHVSet(unsigned int ros, unsigned int drawer, unsigned int channel, float hvSet)
Store requested HV reported by DCS for given Tile channel.