ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
13
14 ATH_MSG_DEBUG("in initialize()");
15
16 // initialize superclass
18
19 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
20
21 ATH_CHECK( m_cablingSvc.retrieve() );
22 m_cabling = m_cablingSvc->cablingService();
23
24 ATH_CHECK( m_rawChannelContainerKey.initialize() );
25 ATH_CHECK( m_DQstatusKey.initialize() );
26 ATH_CHECK( m_badChannelsKey.initialize() );
27 ATH_CHECK( m_DCSStateKey.initialize(m_checkDCS) );
28 ATH_CHECK( m_emScaleKey.initialize() );
29
30 using Tile = TileCalibUtils;
31 using namespace Monitored;
32
34 Tile::MAX_ROS - 1, Tile::MAX_DRAWER, Tile::MAX_CHAN);
35
36 return StatusCode::SUCCESS;
37}
38
39
40StatusCode TileRawChannelNoiseMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
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) {
109 if (m_cabling->isDisconnected(ros, drawer, 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
136 if (m_ignoreDisconnectedChannels && m_cabling->isDisconnected(ros, drawer, channel)) {
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}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Declare a monitored scalar variable.
A monitored timer.
const_pointer_type cptr()
Static class providing several utility functions and constants.
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.
Condition object to keep Tile DCS status from DB.
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...
Class that holds Data Quality fragment information and provides functions to extract the data quality...
bool isAdcDQgood(int partition, int drawer, int ch, int gain) const
returns status of single ADC returns False if there are any errors
virtual StatusCode initialize() override
initialize
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
SG::ReadCondHandleKey< TileDCSState > m_DCSStateKey
Name of TileDCSState object in condition store.
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
Name of TileEMScale in condition store.
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Gaudi::Property< std::vector< unsigned int > > m_triggerTypes
std::vector< std::vector< std::vector< int > > > m_ampGroups
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Gaudi::Property< std::vector< int > > m_fragIDsToIgnoreDMUerrors
SG::ReadCondHandleKey< TileBadChannels > m_badChannelsKey
Name of TileBadChannels in condition store.
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t bcid() const
The bunch crossing ID of the event.
uint16_t level1TriggerType() const
The Level-1 trigger type.
const std::vector< StreamTag > & streamTags() const
Get the streams that the event was put in.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
Generic monitoring tool for athena components.
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
EventInfo_v1 EventInfo
Definition of the latest event info version.
void fill(H5::Group &out_file, size_t iterations)
MsgStream & msg
Definition testRead.cxx:32