ATLAS Offline Software
ZdcLEDMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 ZdcLEDMonitorAlgorithm::ZdcLEDMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
10 :AthMonitorAlgorithm(name,pSvcLocator){
11  ATH_MSG_DEBUG("calling the constructor of ZdcLEDMonitorAlgorithm");
12 }
13 
14 
16 
17 
19 
20  ATH_MSG_DEBUG("initializing for the monitoring algorithm");
21 
22  using namespace Monitored;
23  ATH_CHECK( m_ZdcSumContainerKey.initialize() );
24  ATH_CHECK( m_ZdcModuleContainerKey.initialize() );
25 
26  ATH_CHECK( m_eventTypeKey.initialize() );
27  ATH_CHECK( m_DAQModeKey.initialize() );
28 
29  ATH_CHECK( m_robBCIDKey.initialize() );
30 
31  ATH_CHECK( m_LEDTypeKey.initialize() );
32  ATH_CHECK( m_LEDPresampleADCKey.initialize() );
33  ATH_CHECK( m_LEDADCSumKey.initialize() );
34  ATH_CHECK( m_LEDMaxADCKey.initialize() );
35  ATH_CHECK( m_LEDMaxSampleKey.initialize() );
36  ATH_CHECK( m_LEDAvgTimeKey.initialize() );
37 
38  m_ZDCModuleLEDToolIndices = buildToolMap<std::vector<std::vector<int>>>(m_tools,"ZdcModLEDMonitor",m_LEDNames.size(),m_nSides,m_nModules);
39  m_RPDChannelLEDToolIndices = buildToolMap<std::vector<std::vector<int>>>(m_tools,"RPDChanLEDMonitor",m_LEDNames.size(),m_nSides,m_nChannels);
40 
41  //---------------------------------------------------
42  // initialize superclass
43 
45  //---------------------------------------------------
46 
47 }
48 
49 
50 StatusCode ZdcLEDMonitorAlgorithm::fillLEDHistograms(unsigned int DAQMode, const EventContext& ctx ) const {
51 
52  ATH_MSG_DEBUG("calling the fillLEDHistograms function");
53 // ______________________________________________________________________________
54  // declaring & obtaining event-level information of interest
55 // ______________________________________________________________________________
56 
57  // lumi block
58  SG::ReadHandle<xAOD::EventInfo> eventInfo(m_EventInfoKey, ctx); // already checked in fillHistograms that eventInfo is valid
59 
60  auto lumiBlock = Monitored::Scalar<uint32_t>("lumiBlock", eventInfo->lumiBlock());
61  auto bcid = Monitored::Scalar<unsigned int>("bcid", eventInfo->bcid());
62 
63 
66  if (!robBCIDHandle.isValid()) return StatusCode::FAILURE;
67 
68  const xAOD::ZdcModule* moduleSumEventInfo_ptr = 0;
69 
70  SG::ReadHandle<xAOD::ZdcModuleContainer> zdcSums(m_ZdcSumContainerKey, ctx); // already checked in fillHistograms that zdcSums is valid
71  for (const auto& zdcSum : *zdcSums) {
72  if (zdcSum->zdcSide() == 0){
73  moduleSumEventInfo_ptr = zdcSum;
74  }
75  }
76 
77  const std::vector<uint16_t>& robBCIDvec = robBCIDHandle(*moduleSumEventInfo_ptr);
78  if (robBCIDHandle->size() == 0) return StatusCode::FAILURE;
79 
80  unsigned int checkBCID = robBCIDvec[0];
81  for (unsigned int bcid : robBCIDvec) {
82  if (bcid != checkBCID) {
83  ATH_MSG_ERROR("Inconsistent BCIDs in rob header, cannot continue in standalone mode");
84  return StatusCode::FAILURE;
85  }
86  }
87 
88  bcid = checkBCID;
89  }
90 
91 
92  // LED type (event-level info saved in the glocal sum entry of zdcSums)
93  unsigned int iLEDType = 1000;
95  if (!zdcLEDTypeHandle.isAvailable()){
96  ATH_MSG_WARNING("CANNOT find the variable " << m_LEDTypeKey << "!");
97  return StatusCode::SUCCESS;
98  }
99 
100  SG::ReadHandle<xAOD::ZdcModuleContainer> zdcSums(m_ZdcSumContainerKey, ctx); // already checked in fillHistograms that zdcSums is valid
101 
102  for (const auto& zdcSum : *zdcSums) {
103  if (zdcSum->zdcSide() == 0){
104  iLEDType = zdcLEDTypeHandle(*zdcSum);
105  }
106  }
107 
108  if (iLEDType == 1000){
109  ATH_MSG_WARNING("The LED type is unretrieved!");
110  return StatusCode::SUCCESS;
111  }
112  if (iLEDType >= m_LEDNames.size()){
113  ATH_MSG_WARNING("The retrieved LED type is incorrect (larger than 2)!");
114  return StatusCode::SUCCESS;
115  }
116 
117 
118  // trigger passed
119 
120 
121 // ______________________________________________________________________________
122  // declaring & obtaining LED variables of interest for the ZDC modules & RPD channels
123  // filling arrays of monitoring tools (module/channel-level)
124 // ______________________________________________________________________________
125 
127 
128  auto zdcLEDADCSum = Monitored::Scalar<int>("zdcLEDADCSum",-1000);
129  auto zdcLEDMaxADC = Monitored::Scalar<int>("zdcLEDMaxADC",-1000);
130  auto zdcLEDMaxSample = Monitored::Scalar<unsigned int>("zdcLEDMaxSample",1000);
131  auto zdcLEDAvgTime = Monitored::Scalar<float>("zdcLEDAvgTime",-1000);
132 
133  auto rpdLEDADCSum = Monitored::Scalar<int>("rpdLEDADCSum",-1000);
134  auto rpdLEDMaxADC = Monitored::Scalar<int>("rpdLEDMaxADC",-1000);
135  auto rpdLEDMaxSample = Monitored::Scalar<unsigned int>("rpdLEDMaxSample",1000);
136  auto rpdLEDAvgTime = Monitored::Scalar<float>("rpdLEDAvgTime",-1000);
137 
142 
143 
144  if (! zdcModules.isValid() ) {
145  ATH_MSG_WARNING("evtStore() does not contain Collection with name "<< m_ZdcModuleContainerKey);
146  return StatusCode::SUCCESS;
147  }
148 
149 
150 
151  for (const auto zdcMod : *zdcModules){
152  int iside = (zdcMod->zdcSide() > 0)? 1 : 0;
153 
154  if (zdcMod->zdcType() == 0){ // zdc
155  int imod = zdcMod->zdcModule();
156  zdcLEDADCSum = LEDADCSumHandle(*zdcMod);
157  zdcLEDMaxADC = LEDMaxADCHandle(*zdcMod);
158  zdcLEDMaxSample = LEDMaxSampleHandle(*zdcMod);
159  zdcLEDAvgTime = LEDAvgTimeHandle(*zdcMod);
160 
161  fill(m_tools[m_ZDCModuleLEDToolIndices[iLEDType][iside][imod]], lumiBlock, bcid, zdcLEDADCSum, zdcLEDMaxADC, zdcLEDMaxSample, zdcLEDAvgTime);
162  }
163  else if (zdcMod->zdcType() == 1) { // rpd
164  int ichannel = zdcMod->zdcChannel();
165  if (ichannel >= m_nChannels){
166  ATH_MSG_WARNING("The current channel number exceeds the zero-based limit (15): it is " << ichannel);
167  continue;
168  }
169  rpdLEDADCSum = LEDADCSumHandle(*zdcMod);
170  rpdLEDMaxADC = LEDMaxADCHandle(*zdcMod);
171  rpdLEDMaxSample = LEDMaxSampleHandle(*zdcMod);
172  rpdLEDAvgTime = LEDAvgTimeHandle(*zdcMod);
173 
174  fill(m_tools[m_RPDChannelLEDToolIndices[iLEDType][iside][ichannel]], lumiBlock, bcid, rpdLEDADCSum, rpdLEDMaxADC, rpdLEDMaxSample, rpdLEDAvgTime);
175  }
176  }
177 
178  return StatusCode::SUCCESS;
179 }
180 
181 
182 StatusCode ZdcLEDMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
183 
184  ATH_MSG_DEBUG("calling the fillHistograms function");
185 
187  if (! eventInfo.isValid() ) {
188  ATH_MSG_WARNING("cannot retrieve event info from evtStore()!");
189  return StatusCode::SUCCESS;
190  }
191 
192  auto bcid = Monitored::Scalar<unsigned int>("bcid", eventInfo->bcid());
193  auto l1TriggerType = Monitored::Scalar<unsigned int>("l1TriggerType", eventInfo->level1TriggerType());
194  auto lumiBlock = Monitored::Scalar<uint32_t>("lumiBlock", eventInfo->lumiBlock());
195 
196  // fill in the lumi block, BCID and L1 trigger type information without any check
197  // for diagnosis of bad events that, e.g, fail the reconstruction
198  fill("ZdcLEDAllEventsDiagnosis", lumiBlock, bcid, l1TriggerType);
199 
200  unsigned int eventType = ZdcEventInfo::ZdcEventUnknown;
201  unsigned int DAQMode = ZdcEventInfo::DAQModeUndef;
202 
205 
207 
208  if (! zdcSums.isValid() ) {
209  ATH_MSG_WARNING("evtStore() does not contain Collection with name "<< m_ZdcSumContainerKey);
210  return StatusCode::SUCCESS;
211  }
212  for (const auto& zdcSum : *zdcSums) {
213  if (zdcSum->zdcSide() == 0){
214  if (!eventTypeHandle.isAvailable()){
215  ATH_MSG_WARNING("The global sum entry in zdc sum container can be retrieved; but it does NOT have the variable eventType written as a decoration!");
216  return StatusCode::SUCCESS;
217  }
218 
219  if (!DAQModeHandle.isAvailable()){
220  ATH_MSG_WARNING("The global sum entry in zdc sum container can be retrieved; but it does NOT have the variable DAQMode written as a decoration!");
221  return StatusCode::SUCCESS;
222  }
223 
224  eventType = eventTypeHandle(*zdcSum);
225  DAQMode = DAQModeHandle(*zdcSum);
226  }
227  }
228 
229  ATH_MSG_DEBUG("The event type is: " << eventType);
230 
232  ATH_MSG_WARNING("The zdc sum container can be retrieved from the evtStore() but");
233  ATH_MSG_WARNING("Either the event type or the DAQ mode is the default unknown value");
234  ATH_MSG_WARNING("Most likely, there is no global sum (side == 0) entry in the zdc sum container");
235  return StatusCode::SUCCESS;
236  }
237 
238  if (eventType == ZdcEventInfo::ZdcEventLED){
239  return fillLEDHistograms(DAQMode, ctx);
240  }
241 
242  ATH_MSG_WARNING("Event type should be LED but it is NOT");
243  return StatusCode::SUCCESS;
244 }
245 
ZdcLEDMonitorAlgorithm::ZdcLEDMonitorAlgorithm
ZdcLEDMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ZdcLEDMonitorAlgorithm.cxx:9
ZDCPulseAnalyzer.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ZdcLEDMonitorAlgorithm::~ZdcLEDMonitorAlgorithm
virtual ~ZdcLEDMonitorAlgorithm()
Definition: ZdcLEDMonitorAlgorithm.cxx:15
ZdcLEDMonitorAlgorithm::m_LEDPresampleADCKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_LEDPresampleADCKey
Definition: ZdcLEDMonitorAlgorithm.h:62
xAOD::ZdcModule_v1
Class containing ZDC Module information.
Definition: ZdcModule_v1.h:25
AthMonitorAlgorithm::m_EventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
Key for retrieving EventInfo from StoreGate.
Definition: AthMonitorAlgorithm.h:362
ZdcLEDMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: ZdcLEDMonitorAlgorithm.cxx:182
ZdcLEDMonitorAlgorithm::m_LEDTypeKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_LEDTypeKey
Definition: ZdcLEDMonitorAlgorithm.h:61
ZdcEventInfo::ZdcEventUnknown
@ ZdcEventUnknown
Definition: ZdcEventInfo.h:16
ZdcLEDMonitorAlgorithm::m_robBCIDKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_robBCIDKey
Definition: ZdcLEDMonitorAlgorithm.h:58
ZdcEventInfo::DAQMode
DAQMode
Definition: ZdcEventInfo.h:17
ZdcLEDMonitorAlgorithm::m_ZdcModuleContainerKey
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_ZdcModuleContainerKey
Definition: ZdcLEDMonitorAlgorithm.h:53
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
ZdcLEDMonitorAlgorithm.h
ZdcLEDMonitorAlgorithm::m_RPDChannelLEDToolIndices
std::vector< std::vector< std::vector< int > > > m_RPDChannelLEDToolIndices
Definition: ZdcLEDMonitorAlgorithm.h:47
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
ZdcLEDMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: ZdcLEDMonitorAlgorithm.cxx:18
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
ZdcLEDMonitorAlgorithm::m_ZdcSumContainerKey
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_ZdcSumContainerKey
Definition: ZdcLEDMonitorAlgorithm.h:52
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
ZdcLEDMonitorAlgorithm::m_nModules
static const int m_nModules
Definition: ZdcLEDMonitorAlgorithm.h:40
ZdcLEDMonitorAlgorithm::m_nSides
static const int m_nSides
Definition: ZdcLEDMonitorAlgorithm.h:39
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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.
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ZdcLEDMonitorAlgorithm::m_LEDMaxSampleKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_LEDMaxSampleKey
Definition: ZdcLEDMonitorAlgorithm.h:65
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
ZdcLEDMonitorAlgorithm::m_LEDAvgTimeKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_LEDAvgTimeKey
Definition: ZdcLEDMonitorAlgorithm.h:66
ZdcLEDMonitorAlgorithm::m_LEDMaxADCKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_LEDMaxADCKey
Definition: ZdcLEDMonitorAlgorithm.h:64
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
ZdcEventInfo::DAQModeUndef
@ DAQModeUndef
Definition: ZdcEventInfo.h:17
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
ZdcLEDMonitorAlgorithm::m_LEDADCSumKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_LEDADCSumKey
Definition: ZdcLEDMonitorAlgorithm.h:63
ZdcLEDMonitorAlgorithm::fillLEDHistograms
StatusCode fillLEDHistograms(unsigned int DAQMode, const EventContext &ctx) const
Definition: ZdcLEDMonitorAlgorithm.cxx:50
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ZdcLEDMonitorAlgorithm::m_nChannels
static const int m_nChannels
Definition: ZdcLEDMonitorAlgorithm.h:41
xAOD::EventInfo_v1::level1TriggerType
uint16_t level1TriggerType() const
The Level-1 trigger type.
ZdcEventInfo::Standalone
@ Standalone
Definition: ZdcEventInfo.h:17
ZdcLEDMonitorAlgorithm::m_LEDNames
const std::vector< std::string > m_LEDNames
Definition: ZdcLEDMonitorAlgorithm.h:42
ZdcLEDMonitorAlgorithm::m_eventTypeKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_eventTypeKey
Definition: ZdcLEDMonitorAlgorithm.h:55
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
ZdcLEDMonitorAlgorithm::m_ZDCModuleLEDToolIndices
std::vector< std::vector< std::vector< int > > > m_ZDCModuleLEDToolIndices
Definition: ZdcLEDMonitorAlgorithm.h:46
SG::ReadDecorHandle::isAvailable
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
RpdSubtractCentroidTool.h
ZdcLEDMonitorAlgorithm::m_DAQModeKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_DAQModeKey
Definition: ZdcLEDMonitorAlgorithm.h:56
ZdcEventInfo::ZdcEventLED
@ ZdcEventLED
Definition: ZdcEventInfo.h:16