ATLAS Offline Software
TileRawChannelNoiseMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 #include "StoreGate/ReadHandle.h"
11 
13 
14  ATH_MSG_DEBUG("in initialize()");
15 
16  // initialize superclass
18 
20 
21  ATH_CHECK( m_cablingSvc.retrieve() );
22  m_cabling = m_cablingSvc->cablingService();
23 
29 
30  using Tile = TileCalibUtils;
31  using namespace Monitored;
32 
33  m_ampGroups = buildToolMap<std::vector<std::vector<int>>>(m_tools, "TileRawChannelNoise",
34  Tile::MAX_ROS - 1, Tile::MAX_DRAWER, Tile::MAX_CHAN);
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 
41 
42  // In case you want to measure the execution time
43  auto timer = Monitored::Timer("TIME_execute");
44 
45  const xAOD::EventInfo* eventInfo = GetEventInfo(ctx).get();
46 
47 
48  if (msgLvl(MSG::DEBUG)) {
49  msg(MSG::DEBUG) << "Run = " << eventInfo->runNumber()
50  << " LB = " << eventInfo->lumiBlock()
51  << " Evt = " << eventInfo->eventNumber()
52  << " BCID = " << eventInfo->bcid()
53  << " lvl1 = 0x" << std::hex << eventInfo->level1TriggerType() << std::dec;
54 
55  const std::vector<xAOD::EventInfo::StreamTag>& evtStreamTags = eventInfo->streamTags();
56  if (!evtStreamTags.empty()) {
57  msg(MSG::DEBUG) << " stream name/type:";
58  for (const auto& evtStreamTag : evtStreamTags) {
59  msg(MSG::DEBUG) << " " << evtStreamTag.name() << "/" << evtStreamTag.type();
60  }
61  }
62 
63  msg(MSG::DEBUG) << endmsg;
64  }
65 
66 
67  unsigned int lvl1TriggerType = eventInfo->level1TriggerType();
68 
69  if (m_triggerTypes.empty()
70  || std::find( m_triggerTypes.begin(), m_triggerTypes.end(), lvl1TriggerType) != m_triggerTypes.end()) {
71 
72  const TileDQstatus* dqStatus = SG::makeHandle(m_DQstatusKey, ctx).get();
73  const TileDCSState* dcsState = m_checkDCS ? SG::ReadCondHandle(m_DCSStateKey, ctx).cptr() : nullptr;
74 
76 
78  ATH_CHECK( emScale.isValid() );
79 
81  ATH_CHECK( rawChannelContainer.isValid() );
82 
83  // What is the unit used to store info in the RawChannelContainer ?
84  TileRawChannelUnit::UNIT rawChannelUnit = rawChannelContainer->get_unit();
85  bool recalibrate(false);
86  if (rawChannelUnit != TileRawChannelUnit::ADCcounts) {
87  ATH_MSG_VERBOSE( " RawChannel Units is = " << rawChannelUnit << " => recalibrating in ADC counts" );
88  recalibrate = true;
89  }
90 
91  for (const TileRawChannelCollection* rawChannelCollection : *rawChannelContainer) {
92  if (rawChannelCollection->empty() ) continue;
93 
94  if (rawChannelCollection->getLvl1Type() != lvl1TriggerType) {
95  ATH_MSG_DEBUG("Level1 Trigger Type in Tile raw channels [0x" << std::hex
96  << rawChannelCollection->getLvl1Type() << "] != [0x"
97  << lvl1TriggerType << std::dec << "] from the event info");
98  continue;
99  }
100 
101  HWIdentifier adc_id = rawChannelCollection->front()->adc_HWID();
102  int ros = m_tileHWID->ros(adc_id);
103  int drawer = m_tileHWID->drawer(adc_id);
104  unsigned int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
105  int partition = ros - 1;
106 
107  unsigned int nBadOrDisconnectedChannels = 0;
108  for (unsigned int channel = 0; channel < TileCalibUtils::MAX_CHAN; ++channel) {
110  ++nBadOrDisconnectedChannels;
111  }
112  }
113 
114  unsigned int nRequiredChannels = TileCalibUtils::MAX_CHAN - nBadOrDisconnectedChannels;
115  if (rawChannelCollection->size() < nRequiredChannels) {
116  ATH_MSG_DEBUG("Number of Tile channels with digits [" << rawChannelCollection->size()
117  << "] less than expected [" << nRequiredChannels << "]");
118  continue;
119  }
120 
121  bool checkDQ = true;
122 
123  int fragId = rawChannelCollection->identify();
124  if (std::binary_search(m_fragIDsToIgnoreDMUerrors.begin(), m_fragIDsToIgnoreDMUerrors.end(), fragId)) {
125  checkDQ = false;
126  }
127 
128  for (const TileRawChannel* rawChannel : *rawChannelCollection) {
129 
130  adc_id = rawChannel->adc_HWID();
131  int channel = m_tileHWID->channel(adc_id);
132  int adc = m_tileHWID->adc(adc_id);
133 
134  if (adc != m_gain) continue;
135 
137  ATH_MSG_VERBOSE(m_tileHWID->to_string(adc_id) << ": Disconnected => skipping!");
138  continue;
139  }
140 
141  if (checkDQ && !(dqStatus->isAdcDQgood(ros, drawer, channel, adc))) {
142  ATH_MSG_VERBOSE(m_tileHWID->to_string(adc_id) << ": DQ is BAD => skipping!");
143  continue;
144  }
145 
146  if (m_checkDCS && dcsState->isStatusBad(ros, drawer, channel)) {
147  ATH_MSG_VERBOSE(m_tileHWID->to_string(adc_id) << ": DCS is Bad => skipping!");
148  continue;
149  }
150 
151  if (badChannels->getAdcStatus(adc_id).isBad()) {
152  ATH_MSG_VERBOSE(m_tileHWID->to_string(adc_id) << ": Status is BAD => skipping!");
153  continue;
154  }
155 
156  float amplitude = rawChannel->amplitude();
157  if (recalibrate) {
158  amplitude = emScale->calibrateChannel(drawerIdx, channel, adc, amplitude,
159  rawChannelUnit, TileRawChannelUnit::ADCcounts);
160  }
161 
162  auto monAmplitude = Monitored::Scalar<float>("amplitude", amplitude);
163  fill(m_tools[m_ampGroups[partition][drawer][channel]], monAmplitude);
164 
165  }
166  }
167  }
168 
169 
170  fill("TileRawChanNoiseMonExecuteTime", timer);
171 
172  return StatusCode::SUCCESS;
173 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
TileRawChannelNoiseMonitorAlgorithm::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileRawChannelNoiseMonitorAlgorithm.h:79
TileCalibUtils.h
TileRawChannelNoiseMonitorAlgorithm::m_emScaleKey
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
Name of TileEMScale in condition store.
Definition: TileRawChannelNoiseMonitorAlgorithm.h:70
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TileDCSState::isStatusBad
bool isStatusBad(unsigned int ros, unsigned int drawer) const
Return true if given Tile drawer considered as bad by summary drawer states per LVPS otherwise return...
Definition: TileDCSState.h:320
TileRawChannelNoiseMonitorAlgorithm::m_cablingSvc
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
Definition: TileRawChannelNoiseMonitorAlgorithm.h:76
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
TileRawChannelNoiseMonitorAlgorithm::m_DQstatusKey
SG::ReadHandleKey< TileDQstatus > m_DQstatusKey
Definition: TileRawChannelNoiseMonitorAlgorithm.h:49
ReadCondHandle.h
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
TileRawChannelNoiseMonitorAlgorithm::m_ignoreDisconnectedChannels
Gaudi::Property< bool > m_ignoreDisconnectedChannels
Definition: TileRawChannelNoiseMonitorAlgorithm.h:43
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TileHWID::ros
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition: TileHWID.h:167
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TileEMScale::calibrateChannel
float calibrateChannel(unsigned int drawerIdx, unsigned int channel, unsigned int adc, float amplitude, TileRawChannelUnit::UNIT rawDataUnitIn, TileRawChannelUnit::UNIT rawDataUnitOut) const
Calibrate a Tile channel.
Definition: TileEMScale.cxx:136
TileDQstatus
Class that holds Data Quality fragment information and provides functions to extract the data quality...
Definition: TileDQstatus.h:49
TileHWID::adc
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition: TileHWID.h:193
TileRawChannelNoiseMonitorAlgorithm::m_cabling
const TileCablingService * m_cabling
Definition: TileRawChannelNoiseMonitorAlgorithm.h:80
Tile
Definition: TileVolumeBuilder.h:43
TileHWID.h
TileRawChannelNoiseMonitorAlgorithm::m_triggerTypes
Gaudi::Property< std::vector< unsigned int > > m_triggerTypes
Definition: TileRawChannelNoiseMonitorAlgorithm.h:40
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
TileRawChannelNoiseMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TileRawChannelNoiseMonitorAlgorithm.cxx:40
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
TileRawChannelNoiseMonitorAlgorithm::m_rawChannelContainerKey
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Definition: TileRawChannelNoiseMonitorAlgorithm.h:58
TileRawChannel
Definition: TileRawChannel.h:35
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileRawChannelNoiseMonitorAlgorithm::m_ampGroups
std::vector< std::vector< std::vector< int > > > m_ampGroups
Definition: TileRawChannelNoiseMonitorAlgorithm.h:82
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
maskDeadModules.ros
ros
Definition: maskDeadModules.py:35
TileRawChannelNoiseMonitorAlgorithm::m_badChannelsKey
SG::ReadCondHandleKey< TileBadChannels > m_badChannelsKey
Name of TileBadChannels in condition store.
Definition: TileRawChannelNoiseMonitorAlgorithm.h:64
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
TileRawChannelUnit::UNIT
UNIT
Definition: TileRawChannelUnit.h:16
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
TileDQstatus::isAdcDQgood
bool isAdcDQgood(int partition, int drawer, int ch, int gain) const
returns status of single ADC returns False if there are any errors
Definition: TileDQstatus.cxx:178
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
TileRawChannelNoiseMonitorAlgorithm.h
TileRawChannelCollection
Definition: TileRawChannelCollection.h:12
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TileRawChannelNoiseMonitorAlgorithm::m_DCSStateKey
SG::ReadCondHandleKey< TileDCSState > m_DCSStateKey
Name of TileDCSState object in condition store.
Definition: TileRawChannelNoiseMonitorAlgorithm.h:55
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
TileBadChannels::getAdcStatus
const TileBchStatus & getAdcStatus(const HWIdentifier adc_id) const
Return Tile ADC status.
Definition: TileBadChannels.cxx:24
xAOD::EventInfo_v1::streamTags
const std::vector< StreamTag > & streamTags() const
Get the streams that the event was put in.
Definition: EventInfo_v1.cxx:283
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
TileCablingService::isDisconnected
bool isDisconnected(int ros, int drawer, int channel) const
Definition: TileCablingService.cxx:2461
TileHWID::drawer
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition: TileHWID.h:171
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
TileRawChannelNoiseMonitorAlgorithm::m_checkDCS
Gaudi::Property< bool > m_checkDCS
Definition: TileRawChannelNoiseMonitorAlgorithm.h:39
DEBUG
#define DEBUG
Definition: page_access.h:11
python.Classes.TileCalibUtils
TileCalibUtils
Definition: TileCalib/TileCalibBlobObjs/python/Classes.py:5
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
xAOD::EventInfo_v1::level1TriggerType
uint16_t level1TriggerType() const
The Level-1 trigger type.
TileDCSState
Condition object to keep Tile DCS status from DB.
Definition: TileDCSState.h:24
TileRawChannelNoiseMonitorAlgorithm::m_fragIDsToIgnoreDMUerrors
Gaudi::Property< std::vector< int > > m_fragIDsToIgnoreDMUerrors
Definition: TileRawChannelNoiseMonitorAlgorithm.h:46
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition: TileCalibUtils.cxx:60
TileAANtupleConfig.rawChannelContainer
rawChannelContainer
Definition: TileAANtupleConfig.py:120
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TileHWID::to_string
std::string to_string(const HWIdentifier &id, int level=0) const
extract all fields from HW identifier HWIdentifier get_all_fields ( const HWIdentifier & id,...
Definition: TileHWID.cxx:50
ReadHandle.h
Handle class for reading from StoreGate.
TileCalibUtils::MAX_CHAN
static const unsigned int MAX_CHAN
Number of channels in drawer.
Definition: TileCalibUtils.h:141
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
TileRawChannelNoiseMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TileRawChannelNoiseMonitorAlgorithm.cxx:12
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
TileRawChannelUnit::ADCcounts
@ ADCcounts
Definition: TileRawChannelUnit.h:17
TileRawChannelNoiseMonitorAlgorithm::m_gain
Gaudi::Property< int > m_gain
Definition: TileRawChannelNoiseMonitorAlgorithm.h:38
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67