ATLAS Offline Software
FwdZDCMonitoringAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "FwdZDCMonitoringAlg.h"
7 
8 
9 FwdZDCMonitoringAlg::FwdZDCMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
10  : AthMonitorAlgorithm(name, pSvcLocator) {}
11 
13 
15 {
16  ATH_CHECK(m_zdcModuleContainerKey.initialize());
19  ATH_CHECK( m_eventInfoDecorKey.initialize() );
21 }
22 
23 StatusCode FwdZDCMonitoringAlg::fillHistograms(const EventContext &context) const
24 {
25  const auto &trigDecTool = getTrigDecisionTool();
26 
28  // access ZDC modules
30  // access ZDC aux data
32 
33  if (!zdcModules.isValid())
34  {
35  ATH_MSG_DEBUG("evtStore() does not contain Zdc Collection with name " << m_zdcModuleContainerKey << ", is the Zdc present in this sample?");
36  return StatusCode::SUCCESS;
37  }
39  ATH_MSG_WARNING("Error in LUCROD decoding, cannot write monitoring histograms. Skipping this event");
40  return StatusCode::SUCCESS;
41  }
42  for (const auto &trig : m_triggerList)
43  {
44  if (!trigDecTool->isPassed(trig, TrigDefs::Physics))
45  {
46  continue;
47  }
48 
49  ATH_MSG_DEBUG("Chain " << trig << " is passed: YES");
50 
51  auto TrigCounts = Monitored::Scalar<std::string>("TrigCounts", trig);
52  fill("ZDCall", TrigCounts);
53 
54  // declare the quantities which should be monitored
55  auto e_A = Monitored::Scalar<float>("e_A", 0.0); // ZDC ADC on Side A
56  auto e_C = Monitored::Scalar<float>("e_C", 0.0); // ZDC ADC on Side C
57  auto moduleEnergy = Monitored::Scalar<float>("moduleEnergy", 0.0);
58  auto moduleNum = Monitored::Scalar<float>("moduleNum", 0.0);
59 
60  // read single modules
61  for (const auto zdcModule : *zdcModules)
62  {
63  if (zdcModule->zdcType() == 0)
64  { // type = 0 are big modules, type = 1 the pixels
65  // Side A
66  if (zdcModule->zdcSide() > 0)
67  {
68  moduleEnergy = zdcModuleCalibEnergyHandle(*zdcModule);
69  moduleNum = zdcModule->zdcModule();
70  e_A += zdcModuleCalibEnergyHandle(*zdcModule);
71  fill(trig + "_expert", moduleEnergy, moduleNum);
72  fill("ZDCall", moduleEnergy, moduleNum);
73  }
74  // Side C
75  if (zdcModule->zdcSide() < 0)
76  {
77  moduleEnergy = zdcModuleCalibEnergyHandle(*zdcModule);
78  moduleNum = zdcModule->zdcModule() + 4.;
79  e_C += zdcModuleCalibEnergyHandle(*zdcModule);
80  fill(trig + "_expert", moduleEnergy, moduleNum);
81  fill("ZDCall", moduleEnergy, moduleNum);
82  }
83  }
84  }
85  fill(trig + "_expert", e_A, e_C);
86  fill("ZDCall", e_A, e_C);
87  }
88  return StatusCode::SUCCESS;
89 }
FwdZDCMonitoringAlg.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
FwdZDCMonitoringAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &context) const override
adds event to the monitoring histograms
Definition: FwdZDCMonitoringAlg.cxx:23
FwdZDCMonitoringAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: FwdZDCMonitoringAlg.cxx:14
FwdZDCMonitoringAlg::m_triggerList
Gaudi::Property< std::vector< std::string > > m_triggerList
Definition: FwdZDCMonitoringAlg.h:32
AthMonitorAlgorithm::m_EventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
Key for retrieving EventInfo from StoreGate.
Definition: AthMonitorAlgorithm.h:362
AthMonitorAlgorithm::getTrigDecisionTool
const ToolHandle< Trig::TrigDecisionTool > & getTrigDecisionTool() const
Get the trigger decision tool member.
Definition: AthMonitorAlgorithm.cxx:189
FwdZDCMonitoringAlg::m_zdcModuleContainerKey
SG::ReadHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleContainerKey
Definition: FwdZDCMonitoringAlg.h:34
ZdcEventInfo::DECODINGERROR
@ DECODINGERROR
Definition: ZdcEventInfo.h:19
FwdZDCMonitoringAlg::m_eventInfoDecorKey
SG::ReadDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition: FwdZDCMonitoringAlg.h:39
FwdZDCMonitoringAlg::~FwdZDCMonitoringAlg
virtual ~FwdZDCMonitoringAlg()
Definition: FwdZDCMonitoringAlg.cxx:12
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
FwdZDCMonitoringAlg::m_zdcModuleCalibEnergyKey
SG::ReadDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleCalibEnergyKey
Definition: FwdZDCMonitoringAlg.h:37
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
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
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.
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
xAOD::EventInfo_v1::ForwardDet
@ ForwardDet
The forward detectors.
Definition: EventInfo_v1.h:338
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::EventInfo_v1::isEventFlagBitSet
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
Definition: EventInfo_v1.cxx:703
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
FwdZDCMonitoringAlg::FwdZDCMonitoringAlg
FwdZDCMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FwdZDCMonitoringAlg.cxx:9
ZdcEventInfo.h
Define enumerations for event-level ZDC data.