ATLAS Offline Software
Loading...
Searching...
No Matches
PixelRDOValidationCommons.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
7#include "Identifier/Identifier.h"
9#include <cstddef>
10
12{
13 ATH_CHECK(detStore()->retrieve(m_idHelper, "PixelID"));
14 return StatusCode::SUCCESS;
15}
16
17StatusCode PixelRDOValidationCommons::execute(const EventContext& ctx) const
18{
19 size_t nb_mon_rdos = 0, nb_ref_rdos = 0;
20
21 TSortedRDOContainer reference_rdos;
22 ATH_CHECK(makeSortedReferenceRDOs(ctx, reference_rdos, nb_ref_rdos));
23
24 TSortedRDOContainer monitored_rdos;
25 ATH_CHECK(makeSortedMonitoredRDOs(ctx, monitored_rdos, nb_mon_rdos));
26
27 if (nb_ref_rdos == 0) {
28 ATH_MSG_ERROR("empty reference container");
29 return StatusCode::FAILURE;
30 }
31 if (nb_mon_rdos == 0) {
32 ATH_MSG_ERROR("empty monitored container");
33 return StatusCode::FAILURE;
34 }
35
36 ATH_MSG_DEBUG("nb modules: ref: " << reference_rdos.size() << ", mon: "
37 << monitored_rdos.size());
38 ATH_MSG_DEBUG("nb RDOs: ref: " << nb_ref_rdos << ", mon: " << nb_mon_rdos);
39
40 size_t err_module_missing_from_ref = 0;
41 size_t err_module_missing_from_mon = 0;
42 size_t err_rdo_missing_from_ref = 0;
43 size_t err_rdo_missing_from_mon = 0;
44 size_t err_rdo_contents = 0;
45
46 // Copy reference module IDs to check if some are not in monitored
47 std::set<Identifier> ref_modules;
48 for (auto const & [module_id, _]: reference_rdos) {
49 ref_modules.insert(module_id);
50 }
51
52 for (auto const & [module_id, mon_module_rdos]: monitored_rdos) {
53 auto const ref_module_rdos_it = reference_rdos.find(module_id);
54 if (ref_module_rdos_it == reference_rdos.end()) {
55 ATH_MSG_DEBUG("module missing from ref: " << module_id);
56 err_module_missing_from_ref += 1;
57 continue;
58 }
59
60 // This modules exists in mon
61 ref_modules.erase(module_id);
62
63 auto const & ref_module_rdos = ref_module_rdos_it->second;
64
65 // Copy reference RDO IDs to check if some are not in monitored
66 std::set<Identifier> ref_rdo_ids;
67 for (auto const & [ref_rdo_id, _]: ref_module_rdos) {
68 ref_rdo_ids.insert(ref_rdo_id);
69 }
70
71 for (auto const & [mon_rdo_id, mon_rdo_word]: mon_module_rdos) {
72 auto const ref_rdo_it = ref_module_rdos.find(mon_rdo_id);
73 if (ref_rdo_it == ref_module_rdos.end()) {
74 ATH_MSG_DEBUG("RDO missing from ref"
75 << ": module ID: " << module_id
76 << ", RDO ID: " << mon_rdo_id);
77 err_rdo_missing_from_ref += 1;
78 continue;
79 }
80
81 // This RDO exists in mon
82 ref_rdo_ids.erase(mon_rdo_id);
83
84 auto const & ref_rdo = *ref_rdo_it;
85 if (mon_rdo_word != ref_rdo.second) {
86 ATH_MSG_DEBUG("RDO words mismatch"
87 << ": module ID: " << module_id
88 << ", RDO id: " << mon_rdo_id
89 << ", ref: " << ref_rdo.second
90 << ", mon: " << mon_rdo_word);
91 err_rdo_contents += 1;
92 }
93 }
94
95 // All remaining RDO IDs in ref_rdo_ids were not in monitored
96 for (auto const & rdo_id: ref_rdo_ids) {
97 ATH_MSG_DEBUG("RDO missing from mon"
98 << ": module ID: " << module_id
99 << ", RDO ID:" << rdo_id);
100 err_rdo_missing_from_mon += 1;
101 }
102 }
103
104 // All remaining module in ref_modules were not in monitored
105 for (auto const & module_id: ref_modules) {
106 ATH_MSG_DEBUG("module missing from mon: " << module_id);
107 err_module_missing_from_mon += 1;
108 }
109
110 if (err_module_missing_from_mon || err_module_missing_from_ref
111 || err_rdo_missing_from_mon || err_rdo_missing_from_ref
112 || err_rdo_contents)
113 {
114 ATH_MSG_ERROR("error summary"
115 << " (total collections: " << reference_rdos.size()
116 << ", total RDOs: ref: " << nb_ref_rdos << ", mon: " << nb_mon_rdos << ")"
117 << ": module missing from ref: " << err_module_missing_from_ref
118 << ", module missing from mon: " << err_module_missing_from_mon
119 << ", RDO missing from ref: " << err_rdo_missing_from_ref
120 << ", RDO missing from mon: " << err_rdo_missing_from_mon
121 << ", RDO contents: " << err_rdo_contents
122 );
123 return StatusCode::FAILURE;
124 } else {
125 ATH_MSG_DEBUG("containers match");
126 }
127
128 return StatusCode::SUCCESS;
129}
130
132 SG::ReadHandle<PixelRDO_Container> & sg_rdos_handle,
133 TSortedRDOContainer & sorted_rdos, size_t & nb_sorted_rdos) const
134{
135 sorted_rdos.clear();
136 nb_sorted_rdos = 0;
137
138 for (const auto* coll : *sg_rdos_handle) {
139 if (coll == nullptr || coll->size() == 0) continue;
140 std::map<Identifier, unsigned int> & module_rdos = sorted_rdos[coll->identify()];
141 for (const PixelRDORawData* rdo : *coll) {
142 module_rdos[rdo->identify()] = rdo->getWord();
143 nb_sorted_rdos += 1;
144 }
145 }
146 return StatusCode::SUCCESS;
147}
148
151 TSortedRDOContainer & sorted_rdos, size_t & nb_sorted_rdos) const
152{
153 sorted_rdos.clear();
154 nb_sorted_rdos = 0;
155
156 using PixelRawDataContainerProxy =
158 using PixelRawDataProxy = PhaseII::PixelRawDataTypeTraits<>::RawDataProxy;
159 auto pixel_rdo_container_collection_proxy =
161
162 for (PixelRawDataContainerProxy module_rdo_container_proxy :
163 pixel_rdo_container_collection_proxy) {
164 if (module_rdo_container_proxy.empty()) {
165 continue;
166 }
167 const IdentifierHash module_hash = module_rdo_container_proxy.identifyHash();
168 //The Phase-II EDM does not store the module ID: retrieve it from its hash
169 const Identifier module_id = m_idHelper->wafer_id(module_hash);
170 std::map<Identifier, unsigned int> & module_rdos = sorted_rdos[module_id];
171
172 for (PixelRawDataProxy rdo: module_rdo_container_proxy) {
173 //The Phase-II EDM does not store the RDO ID: make it from its consituents
174 const int16_t row = rdo.coordinates()[0];
175 const int16_t col = rdo.coordinates()[1];
176 Identifier rdo_id = m_idHelper->pixel_id(module_id, row, col);
177 module_rdos[rdo_id] = rdo.dataWord();
178 nb_sorted_rdos += 1;
179 }
180 }
181 return StatusCode::SUCCESS;
182}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
std::map< Identifier, std::map< Identifier, unsigned int > > TSortedRDOContainer
const ServiceHandle< StoreGateSvc > & detStore() const
This is a "hash" representation of an Identifier.
auto makeRawDataCollectionProxy(const T_RawDataContainerCollection &collection)
Create the top level container proxy for an RDO container collection (read only).
typename RawData::details::traits< ContainerNonConst >::template RawDataProxy< accessPolicy > RawDataProxy
PhaseII::RawDataContainerProxy< typename Utils::ContainerAccessHelper< T_RawDataContainer, accessPolicy >::ContainerType, RawDataProxy > RawDataContainerProxy
virtual StatusCode initialize() override
StatusCode makeSortedPhaseIIRDOs(SG::ReadHandle< PhaseIIPixelRawDataContainer > &sg_rdos_handle, TSortedRDOContainer &sorted_rdos, size_t &nb_sorted_rdos) const
virtual StatusCode makeSortedMonitoredRDOs(const EventContext &ctx, TSortedRDOContainer &monitored_rdos, size_t &nb_monitored_rdos) const =0
virtual StatusCode execute(const EventContext &ctx) const override
StatusCode makeSortedRDOs(SG::ReadHandle< PixelRDO_Container > &sg_rdos_handle, TSortedRDOContainer &sorted_rdos, size_t &nb_sorted_rdos) const
virtual StatusCode makeSortedReferenceRDOs(const EventContext &ctx, TSortedRDOContainer &reference_rdos, size_t &nb_reference_rdos) const =0