Commit f4b5a138 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'move.TileConditions-20190114' into 'master'

TileConditions: A few optimizations.

See merge request atlas/athena!20349
parents 8e930ab2 f9db275d
......@@ -19,6 +19,7 @@
*/
#include <map>
#include <vector>
class TileBadChannels {
......@@ -54,7 +55,7 @@ class TileBadChannels {
* @brief Store trips probabilities for all Tile drawers
* @param tripsProbs Trips probabilites for all Tile drawers
*/
void setTripsProbabilities(std::vector<std::vector<float>>& tripsProbs);
void setTripsProbabilities(std::vector<std::vector<float>>&& tripsProbs);
/**
* @brief Return trips probabilities for all Tile drawers
......@@ -67,7 +68,7 @@ class TileBadChannels {
* @brief Store Tile drawers masked completely
* @param maskedDrawers Array of Tile drawers (frag identifiers) masked comletely
*/
void setMaskedDrawers(std::vector<int>& maskedDrawers);
void setMaskedDrawers(std::vector<int>&& maskedDrawers);
/**
* @brief Return Tile drawers masked completely
......@@ -80,8 +81,9 @@ class TileBadChannels {
TileBchStatus m_defaultStatus;
std::map<const HWIdentifier, TileBchStatus> m_adcStatus;
std::map<const HWIdentifier, TileBchStatus> m_channelStatus;
typedef std::map<const HWIdentifier, TileBchStatus> BchMap;
BchMap m_adcStatus;
BchMap m_channelStatus;
std::vector<std::vector<float>> m_tripsProbs;
std::vector<int> m_maskedDrawers;
......@@ -96,13 +98,8 @@ CONDCONT_DEF ( TileBadChannels, 136686108);
// inlines
inline
void TileBadChannels::setTripsProbabilities(std::vector<std::vector<float>>& tripsProbs) {
void TileBadChannels::setTripsProbabilities(std::vector<std::vector<float>>&& tripsProbs) {
m_tripsProbs = std::move(tripsProbs);
}
inline
void TileBadChannels::setMaskedDrawers(std::vector<int>& maskedDrawers) {
m_maskedDrawers = std::move(maskedDrawers);
}
#endif // TILECONDITIONS_TILEBADCHANNELS_H
......@@ -229,5 +229,7 @@ bool TileBadChanTool::isDrawerMasked(unsigned int frag_id) const {
SG::ReadCondHandle<TileBadChannels> badChannels(m_badChannelsKey);
const std::vector<int>& maskedDrawers = badChannels->getMaskedDrawers();
return (std::find(maskedDrawers.begin(), maskedDrawers.end(), frag_id) != maskedDrawers.end());
return std::binary_search (maskedDrawers.begin(),
maskedDrawers.end(),
frag_id);
}
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#include "TileConditions/TileBadChannels.h"
#include <algorithm>
TileBadChannels::TileBadChannels() {
......@@ -22,7 +23,7 @@ void TileBadChannels::addAdcStatus(const HWIdentifier channel_id, const HWIdenti
const TileBchStatus& TileBadChannels::getAdcStatus(const HWIdentifier adc_id) const {
std::map<const HWIdentifier, TileBchStatus>::const_iterator adcStatus = m_adcStatus.find(adc_id);
BchMap::const_iterator adcStatus = m_adcStatus.find(adc_id);
if (adcStatus == m_adcStatus.end()) {
return m_defaultStatus;
} else {
......@@ -33,7 +34,7 @@ const TileBchStatus& TileBadChannels::getAdcStatus(const HWIdentifier adc_id) co
const TileBchStatus& TileBadChannels::getChannelStatus(const HWIdentifier channel_id) const {
std::map<const HWIdentifier, TileBchStatus>::const_iterator channelStatus = m_channelStatus.find(channel_id);
BchMap::const_iterator channelStatus = m_channelStatus.find(channel_id);
if (channelStatus == m_channelStatus.end()) {
return m_defaultStatus;
} else {
......@@ -41,3 +42,9 @@ const TileBchStatus& TileBadChannels::getChannelStatus(const HWIdentifier channe
}
}
void TileBadChannels::setMaskedDrawers(std::vector<int>&& maskedDrawers) {
m_maskedDrawers = std::move(maskedDrawers);
std::sort (m_maskedDrawers.begin(), m_maskedDrawers.end());
}
......@@ -255,7 +255,7 @@ StatusCode TileBadChannelsCondAlg::execute() {
}
}
if (!maskedDrawers.empty()) badChannelsData->setMaskedDrawers(maskedDrawers);
if (!maskedDrawers.empty()) badChannelsData->setMaskedDrawers(std::move(maskedDrawers));
// Check if drawer trips probabilities for simulation are exist in DB.
// By special convention trips probabilities are stored in drawer number: 2
......@@ -287,7 +287,7 @@ StatusCode TileBadChannelsCondAlg::execute() {
}
}
badChannelsData->setTripsProbabilities(tripsProbs);
badChannelsData->setTripsProbabilities(std::move(tripsProbs));
} else {
ATH_MSG_INFO("No drawer trips probabilities found in DB");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment