ATLAS Offline Software
JfexInputMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 JfexInputMonitorAlgorithm::JfexInputMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
8  : AthMonitorAlgorithm(name,pSvcLocator)
9 {
10 }
11 
13 
14  ATH_MSG_DEBUG("Initializing JfexInputMonitorAlgorithm algorithm with name: "<< name());
15  ATH_MSG_DEBUG("JfexInputMonitorAlgorith::initialize");
16  ATH_MSG_DEBUG("Package Name "<< m_Grouphist);
17  ATH_MSG_DEBUG("jFexDataTowerKey: "<< m_jFexDataTowerKey);
18  ATH_MSG_DEBUG("jFexEmulatedTowerKey: "<< m_jFexEmulatedTowerKey);
19 
20  // we initialise all the containers that we need
21  ATH_CHECK( m_jFexDataTowerKey.initialize() );
22  ATH_CHECK( m_jFexEmulatedTowerKey.initialize() );
23 
24  ATH_CHECK( m_bcContKey.initialize() );
25 
26 
28 }
29 
30 StatusCode JfexInputMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
31 
32  ATH_MSG_DEBUG("JfexInputMonitorAlgorithm::fillHistograms");
33 
34  // Access jFex tower container
36  if (!jFexTowerContainer.isValid()) {
37  ATH_MSG_WARNING("No jFex Tower container valid in storegate with key: " << m_jFexDataTowerKey);
38  return StatusCode::FAILURE;
39  }
40 
41  // mismatches can be caused by recent/imminent OTF maskings, so track timings
42  auto timeSince = Monitored::Scalar<int>("timeSince", -1);
43  auto timeUntil = Monitored::Scalar<int>("timeUntil", -1);
45  if (larBadChan.isValid()) {
46  timeSince = ctx.eventID().time_stamp() - larBadChan.getRange().start().time_stamp();
47  timeUntil = larBadChan.getRange().stop().time_stamp() - ctx.eventID().time_stamp();
48  }
49  auto EventType = Monitored::Scalar<std::string>("EventType", "Normal");
50  if ((timeSince >= 0 && timeSince < 10)) EventType = "JustAfterMask";
51  else if ((timeUntil >= 0 && timeUntil < 10)) EventType = "JustBeforeMask";
52 
53  auto Decision = Monitored::Scalar<std::string>("Error", "");
54  auto evtNumber = Monitored::Scalar<ULong64_t>("EventNumber", GetEventInfo(ctx)->eventNumber());
55  auto lbnString = Monitored::Scalar<std::string>("LBNString", std::to_string(GetEventInfo(ctx)->lumiBlock()));
56  auto TowerId = Monitored::Scalar<uint32_t>("TowerId", 0);
57  auto TowerSource = Monitored::Scalar<uint32_t>("TowerSource", 0);
58  auto Towereta = Monitored::Scalar<float>("TowerEta", 0.0);
59  auto Towerphi = Monitored::Scalar<float>("TowerPhi", 0.0);
60  auto TowerCount = Monitored::Scalar<uint32_t>("TowerCount", 0);
61  auto TowerRefCount = Monitored::Scalar<uint32_t>("RefTowerCount", 0);
62  auto TowerSat = Monitored::Scalar<int>("TowerSat", 0);
63  auto TowerRefSat = Monitored::Scalar<int>("RefTowerSat", 0);
64 
65  // these next flags are just used for cutmasks, keep them true
66  auto TowerInvalid = Monitored::Scalar<bool>("TowerInvalid", true);
67  auto TowerEmpty = Monitored::Scalar<bool>("TowerEmpty", true);
68 
69 
70 
71  //Run the monitoring only when the input data is filled (it is pre-scaled), otherwise skip
72  if (jFexTowerContainer->empty()) {
73  ATH_MSG_DEBUG("number of jfex towers = " << jFexTowerContainer->size());
74  Decision += "MissingReadout;";
76  return StatusCode::SUCCESS;
77  }
78 
80  if (!jFexEmulatedTowerContainer.isValid()) {
81  ATH_MSG_ERROR("No jFex Tower container valid in storegate with key: " << m_jFexEmulatedTowerKey);
82  return StatusCode::FAILURE;
83  }
84 
85  // towers are uniquely identified by their ID+Source (bad ID design!)
86  std::map<std::pair<uint32_t, int>, const xAOD::jFexTower *> dataTowers;
87  for (const xAOD::jFexTower *tower: *jFexTowerContainer) {
88  dataTowers[std::pair(tower->jFEXtowerID(), tower->Calosource())] = tower;
89  }
90 
91  // check for more dataTowers than expected/emulated
92  if (dataTowers.size() > jFexEmulatedTowerContainer->size()) {
93  Decision = "MissingEmulatedTowers";
94  fill("errors", Decision, timeSince, timeUntil, evtNumber, lbnString, TowerId, TowerSource, Towereta, Towerphi,
95  TowerCount, TowerRefCount, TowerSat, TowerRefSat);
96  ATH_MSG_WARNING(std::string(Decision) << " in event " << evtNumber << " in lb " << std::string(lbnString));
97  }
98 
99  for (const xAOD::jFexTower *tower: *jFexEmulatedTowerContainer) {
100  // check et_count codes match, and saturation bits match
101  TowerId = tower->jFEXtowerID();
102  TowerSource = tower->Calosource();
103  Towereta = tower->eta() + 1e-5;
104  Towerphi = tower->phi();
105  auto dataTowerItr = dataTowers.find(std::pair(uint32_t(TowerId), int(TowerSource)));
106  if (dataTowerItr == dataTowers.end()) {
107  Decision = "MissingDataTower";
108  fill("errors", Decision, timeSince, timeUntil, evtNumber, lbnString, TowerId, TowerSource, Towereta,
109  Towerphi, TowerCount, TowerRefCount, TowerSat, TowerRefSat);
110  ATH_MSG_WARNING(std::string(Decision) << " in event " << evtNumber << " in lb " << std::string(lbnString)
111  << " TowerId=" << TowerId);
112  continue;
113  }
114  TowerRefCount = tower->et_count().at(0);
115  TowerCount = dataTowerItr->second->et_count().at(0);
116  TowerRefSat = int(tower->isjTowerSat().at(0));
117  TowerSat = int(dataTowerItr->second->isjTowerSat().at(0));
118  if (TowerRefCount != TowerCount) {
119  Decision = "CountMismatch";
120  fill("errors", Decision, timeSince, timeUntil, evtNumber, lbnString, TowerId, TowerSource, Towereta,
121  Towerphi, TowerCount, TowerRefCount, TowerSat, TowerRefSat);
122  ATH_MSG_WARNING(std::string(Decision) << " in event " << evtNumber << " in lb " << std::string(lbnString)
123  << " TowerId=" << TowerId << " Count=" << TowerCount << " RefCount="
124  << TowerRefCount << " Sat=" << TowerSat << " RefSat=" << TowerRefSat);
125  }
126  if (TowerRefSat != TowerSat) {
127  Decision = "SatMismatch";
128  fill("errors", Decision, timeSince, timeUntil, evtNumber, lbnString, TowerId, TowerSource, Towereta,
129  Towerphi, TowerCount, TowerRefCount, TowerSat, TowerRefSat);
130  ATH_MSG_WARNING(std::string(Decision) << " in event " << evtNumber << " in lb " << std::string(lbnString)
131  << " TowerId=" << TowerId << " Count=" << TowerCount << " RefCount="
132  << TowerRefCount << " Sat=" << TowerSat << " RefSat=" << TowerRefSat);
133  }
134  // also log the locations of the saturated towers, invalidCodes, and empty codes
135  // only relevant for LAr
136  if (TowerSource != 1) { // (0=barrel, 1=tile, 2=emec, 3=hec, 4=fcal1, 5=fcal2, 6=fcal3)
137  if (TowerSat) {
138  fill(m_Grouphist, Towereta, Towerphi, TowerSat);
139  }
140  if (TowerCount == m_InvalidCode) {
141  fill(m_Grouphist, Towereta, Towerphi, TowerInvalid);
142  } else if (TowerCount == m_EmptyCode) {
143  fill(m_Grouphist, Towereta, Towerphi, TowerEmpty);
144  }
145  }
146  }
147 
148  return StatusCode::SUCCESS;
149 
150 }
JfexInputMonitorAlgorithm::m_jFexDataTowerKey
SG::ReadHandleKey< xAOD::jFexTowerContainer > m_jFexDataTowerKey
Definition: JfexInputMonitorAlgorithm.h:33
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
JfexInputMonitorAlgorithm::m_InvalidCode
unsigned int m_InvalidCode
Definition: JfexInputMonitorAlgorithm.h:39
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
JfexInputMonitorAlgorithm::m_jFexEmulatedTowerKey
SG::ReadHandleKey< xAOD::jFexTowerContainer > m_jFexEmulatedTowerKey
Definition: JfexInputMonitorAlgorithm.h:34
xAOD::jFexTowerContainer
jFexTowerContainer_v1 jFexTowerContainer
Define the latest version of the TriggerTower container.
Definition: jFexTowerContainer.h:14
JfexInputMonitorAlgorithm::JfexInputMonitorAlgorithm
JfexInputMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JfexInputMonitorAlgorithm.cxx:7
JfexInputMonitorAlgorithm::m_EmptyCode
unsigned int m_EmptyCode
Definition: JfexInputMonitorAlgorithm.h:40
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
JfexInputMonitorAlgorithm.h
JfexInputMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: JfexInputMonitorAlgorithm.cxx:30
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
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
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.
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
JfexInputMonitorAlgorithm::m_bcContKey
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
Definition: JfexInputMonitorAlgorithm.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
JfexInputMonitorAlgorithm::m_Grouphist
StringProperty m_Grouphist
Definition: JfexInputMonitorAlgorithm.h:30
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
JfexInputMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: JfexInputMonitorAlgorithm.cxx:12
xAOD::jFexTower_v1
Class describing input data of a LVL1 jFEX.
Definition: jFexTower_v1.h:22
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:328
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.