ATLAS Offline Software
Loading...
Searching...
No Matches
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
7JfexInputMonitorAlgorithm::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
30StatusCode JfexInputMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
31
32 ATH_MSG_DEBUG("JfexInputMonitorAlgorithm::fillHistograms");
33
34 // Access jFex tower container
35 SG::ReadHandle <xAOD::jFexTowerContainer> jFexTowerContainer{m_jFexDataTowerKey, ctx};
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);
44 SG::ReadCondHandle <LArBadChannelCont> larBadChan{m_bcContKey, ctx};
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
79 SG::ReadHandle <xAOD::jFexTowerContainer> jFexEmulatedTowerContainer{m_jFexEmulatedTowerKey, ctx};
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
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.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition EventType.h:92
SG::ReadHandleKey< xAOD::jFexTowerContainer > m_jFexDataTowerKey
SG::ReadHandleKey< xAOD::jFexTowerContainer > m_jFexEmulatedTowerKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
JfexInputMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
initialize
Declare a monitored scalar variable.
const EventIDRange & getRange()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
jFexTower_v1 jFexTower
Define the latest version of the TriggerTower class.
Definition jFexTower.h:15
void fill(H5::Group &out_file, size_t iterations)