Skip to content
Snippets Groups Projects
Commit 74f5c456 authored by Siarhei Harkusha's avatar Siarhei Harkusha Committed by Julien Maurer
Browse files

TileMonitoring: Add channels with masked negative energy and bad quality to DMU errors plot

TileMonitoring: Add channels with masked negative energy and bad quality to DMU errors plot

Tile DQ Frag monitoring algorithm has been updated to:
- add new histograms with number of masked negative energies below threshold per partition;
- add properties with thresholds for negative energies for normal and E cells;
- add channels with masked negative energy and bad quality to DMU errors plot.

MBTS, E4', disconnected channels or channels with bad DQ status are exluded.
parent a4bd5735
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,9 @@ def TileDQFragMonitoringConfig(flags, **kwargs):
from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
result.merge( TileInfoLoaderCfg(flags) )
from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
result.merge( TileEMScaleCondAlgCfg(flags) )
from TileConditions.TileBadChannelsConfig import TileBadChanToolCfg
badChanTool = result.popToolsAndMerge( TileBadChanToolCfg(flags) )
kwargs['TileBadChanTool'] = badChanTool
......@@ -92,6 +95,10 @@ def _TileDQFragMonitoringCore(helper, algConfObj, runNumber, **kwargs):
''' Function to configure TileDQFragMonitorAlgorithm algorithm in the monitoring system.'''
from AthenaCommon.SystemOfUnits import GeV
kwargs.setdefault('MinEnergyChan', -5.0 * GeV)
kwargs.setdefault('MinEnergyGap', -10.0 * GeV)
run = str(runNumber)
# Adding an TileDQFragMonitorAlgorithm algorithm to the helper; try to accommodate old/new configuration styles
......@@ -167,6 +174,7 @@ def _TileDQFragMonitoringCore(helper, algConfObj, runNumber, **kwargs):
dmuErrorLabels += ['0 -> 1023', 'Zeros', 'Two 1023 + ped', 'Jump 2 levels', 'Single Up + ped']
dmuErrorLabels += ['Single Dn + ped', 'Single Up + sig', 'Single Dn + sig', 'Ped > 200 LG']
dmuErrorLabels += ['Single Dn LG_s0', 'Single Dn LG_s6', 'Up LG_s0_s6 or Gap', 'Dn LG_s0_s6 or Gap']
dmuErrorLabels += ['Bad quality', 'Big negative ene']
maxErrors = len(dmuErrorLabels)
......@@ -176,7 +184,7 @@ def _TileDQFragMonitoringCore(helper, algConfObj, runNumber, **kwargs):
ros, module = [int(x) for x in postfix.split('_')[1:]]
moduleName = Tile.getDrawerString(ros + 1, module)
title = 'Run ' + run + ': ' + moduleName + ' DMU Header Errors;DMU'
title = 'Run ' + run + ': ' + moduleName + ' Channel and DMU Header Errors;DMU'
name = 'DMU,Error;TileDigiErrors' + moduleName
tool.defineHistogram(name, title = title, type = 'TH2F', path = 'DMUErrors',
......@@ -231,6 +239,10 @@ def _TileDQFragMonitoringCore(helper, algConfObj, runNumber, **kwargs):
title = '# Not masked negative amplitude')
# 14) Configure histograms with Tile with negative energy below threshold
negEneMapTitle = f"# Negative energy below {kwargs['MinEnergyChan']/GeV} ({kwargs['MinEnergyGap']/GeV} for E cels) GeV"
addTileModuleChannelMapsArray(helper, tileDQFragMonAlg, path = 'Tile/DMUErrors/BadDrawers',
name = 'TileNegativeEnergyMap', run = run, title = negEneMapTitle)
if __name__=='__main__':
......
......@@ -18,6 +18,7 @@ StatusCode TileDQFragMonitorAlgorithm::initialize() {
ATH_MSG_INFO("in initialize()");
ATH_CHECK( detStore()->retrieve(m_tileID) );
ATH_CHECK( detStore()->retrieve(m_tileHWID) );
ATH_CHECK( m_tileBadChanTool.retrieve() );
......@@ -27,6 +28,7 @@ StatusCode TileDQFragMonitorAlgorithm::initialize() {
ATH_CHECK( m_DQstatusKey.initialize() );
ATH_CHECK( m_DCSStateKey.initialize(m_checkDCS) );
ATH_CHECK( m_emScaleKey.initialize() );
ATH_CHECK( m_digitsContainerKey.initialize(SG::AllowEmpty) );
ATH_CHECK( m_rawChannelContainerKey.initialize(SG::AllowEmpty) );
ATH_CHECK( m_eventInfoTileStatusKey.initialize() );
......@@ -46,6 +48,7 @@ StatusCode TileDQFragMonitorAlgorithm::initialize() {
m_badChannelNegNotMaskGroups = Monitored::buildToolMap<int>(m_tools, "TileBadChannelsNegNotMaskMap", Tile::MAX_ROS - 1);
m_badPulseQualityGroups = Monitored::buildToolMap<int>(m_tools, "TileBadPulseQualityMap", Tile::MAX_ROS - 1);
m_negativeEnergyGroups = Monitored::buildToolMap<int>(m_tools, "TileNegativeEnergyMap", Tile::MAX_ROS - 1);
ATH_CHECK( detStore()->retrieve(m_tileInfo, m_infoName) );
m_ADCmaxMinusEps = m_tileInfo->ADCmax() - 0.01;
......@@ -66,6 +69,8 @@ StatusCode TileDQFragMonitorAlgorithm::fillHistograms( const EventContext& ctx )
const TileDQstatus* dqStatus = SG::makeHandle (m_DQstatusKey, ctx).get();
const TileDCSState* dcsState = m_checkDCS ? SG::ReadCondHandle(m_DCSStateKey, ctx).cptr() : nullptr;
SG::ReadCondHandle<TileEMScale> emScale(m_emScaleKey, ctx);
ATH_CHECK( emScale.isValid() );
auto lumiBlock = Monitored::Scalar<int>("lumiBlock", eventInfo->lumiBlock());
......@@ -118,9 +123,10 @@ StatusCode TileDQFragMonitorAlgorithm::fillHistograms( const EventContext& ctx )
int fragId = rawChannelCollection->identify();
int drawer = (fragId & 0x3F); // range 0-63
int ros = fragId >> 8; // range 1-4
unsigned int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
monitoredModule = drawer;
clearDigiError(dmus, errors);
for (const TileRawChannel* rawChannel : *rawChannelCollection) {
HWIdentifier adcId = rawChannel->adc_HWID();
......@@ -129,18 +135,44 @@ StatusCode TileDQFragMonitorAlgorithm::fillHistograms( const EventContext& ctx )
// By convetion errors are saved in pedestal as 100000 + 10000*error
float pedestal = rawChannel->pedestal();
float quality = rawChannel->quality();
float quality = std::abs(rawChannel->quality());
float amplitude = rawChannel->amplitude();
float time = rawChannel->uncorrTime(); // take uncorrected time (if available)
monitoredChannel = channel;
if ((pedestal > 80000. || quality > m_qualityCut)
&& !(m_tileBadChanTool->getAdcStatus(adcId, ctx).isBad()
|| (m_checkDCS && dcsState->isStatusBad(ros, drawer, channel)))) {
if (dqStatus->isChanDQgood(ros, drawer, channel)
&& !(m_tileBadChanTool->getAdcStatus(adcId, ctx).isBad()
|| (m_checkDCS && dcsState->isStatusBad(ros, drawer, channel)))) {
fill(m_tools[m_badPulseQualityGroups[ros - 1]], monitoredModule, monitoredChannel);
}
if (pedestal > 80000. || quality > m_qualityCut) {
fill(m_tools[m_badPulseQualityGroups[ros - 1]], monitoredModule, monitoredChannel);
}
float amplitude = rawChannel->amplitude();
int pmt;
int index;
Identifier cell_id = m_cabling->h2s_cell_id_index (ros, drawer, channel, index, pmt);
if (index >= 0) { // connected channel, exluding MBTS and E4'
if (quality > m_qualityCut) {
bool overflow = (pedestal > 10000. + m_ADCmaskValueMinusEps);
if (!(overflow && gain == TileID::LOWGAIN && amplitude > 0.
&& time > m_timeMinThresh && time < m_timeMaxThresh)) { // overflow in low gain is not masked
int dmu = channel / 3;
setDigiError(dmus, errors, dmu, MAX_DIGI_ERROR + BAD_QUALITY);
}
}
float minEnergy = (m_tileID->sample(cell_id) == TileID::SAMP_E) ? m_minGapEnergy : m_minChannelEnergy;
float energy = emScale->calibrateChannel(drawerIdx, channel, gain, amplitude, rawChannelUnit, TileRawChannelUnit::MegaElectronVolts);
if (energy < minEnergy) {
int dmu = channel / 3;
setDigiError(dmus, errors, dmu, MAX_DIGI_ERROR + BIG_NEGATIVE_AMPLITUDE);
fill(m_tools[m_negativeEnergyGroups[ros - 1]], monitoredModule, monitoredChannel);
}
}
}
if (amplitude < ((gain) ? m_negativeAmplitudeCutHG : m_negativeAmplitudeCutLG)) {
......@@ -191,6 +223,9 @@ StatusCode TileDQFragMonitorAlgorithm::fillHistograms( const EventContext& ctx )
}
}
}
if (!errors.empty()) {
fill(m_tools[m_errorsGroups[ros - 1][drawer]], drawerDMUs, errorsInDMUs);
}
}
}
}
......
......@@ -10,6 +10,7 @@
#include "TileEvent/TileRawChannelContainer.h"
#include "TileConditions/ITileBadChanTool.h"
#include "TileConditions/TileDCSState.h"
#include "TileConditions/TileEMScale.h"
#include "TileConditions/TileCablingSvc.h"
#include "AthenaMonitoring/AthMonitorAlgorithm.h"
......@@ -18,7 +19,7 @@
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/ReadCondHandleKey.h"
class TileID;
class TileHWID;
class TileCablingService;
class TileInfo;
......@@ -63,6 +64,16 @@ class TileDQFragMonitorAlgorithm : public AthMonitorAlgorithm {
Gaudi::Property<float> m_qualityCut{this,
"QualityCut", 254.0, "Monitor Tile channels reconstructed with quality below this cut"};
Gaudi::Property<float> m_timeMinThresh{this,
"TimeMinForAmpCorrection", -12.5, "Correct amplitude is time is above time minimum threshold"};
Gaudi::Property<float> m_timeMaxThresh{this,
"TimeMaxForAmpCorrection", 12.5, "Correct amplitude is time is below time maximum threshold"};
Gaudi::Property<float> m_minChannelEnergy{this,
"MinEnergyChan", -5000.0F, "Normal channel energy threshold for masking"};
Gaudi::Property<float> m_minGapEnergy{this,
"MinEnergyGap", -10000.0F, "Gap channel energy threshold for masking"};
ToolHandle<ITileBadChanTool> m_tileBadChanTool{this,
"TileBadChanTool", "TileBadChanTool", "Tile bad channel tool"};
......@@ -82,6 +93,12 @@ class TileDQFragMonitorAlgorithm : public AthMonitorAlgorithm {
SG::ReadCondHandleKey<TileDCSState> m_DCSStateKey{this,
"TileDCS", "TileDCS", "Input Tile DCS status"};
/**
* @brief Name of TileEMScale in condition store
*/
SG::ReadCondHandleKey<TileEMScale> m_emScaleKey{this,
"TileEMScale", "TileEMScale", "Input Tile EMS calibration constants"};
SG::ReadHandleKey<TileRawChannelContainer> m_rawChannelContainerKey{this,
"TileRawChannelContainer", "TileRawChannelCnt", "Input Tile raw channel container key"};
......@@ -102,12 +119,15 @@ class TileDQFragMonitorAlgorithm : public AthMonitorAlgorithm {
std::vector<int> m_badChannelNegNotMaskGroups;
std::vector<int> m_badPulseQualityGroups;
std::vector<int> m_negativeEnergyGroups;
const TileID* m_tileID{nullptr};
const TileHWID* m_tileHWID{nullptr};
const TileCablingService* m_cabling{nullptr};
static const int MAX_DMU{16};
static const int MAX_CORRUPTED_ERROR{13};
enum TileBadPulse{BAD_QUALITY = MAX_CORRUPTED_ERROR, BIG_NEGATIVE_AMPLITUDE};
// TileInfo
std::string m_infoName = "TileInfo";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment