ATLAS Offline Software
Loading...
Searching...
No Matches
LArSCIdVsIdTest.cxx
Go to the documentation of this file.
1#include "LArSCIdVsIdTest.h"
2
3#include "CaloDetDescr/CaloDetDescrElement.h"
4
5bool inRange(const double* boundaries, const double value, const double tolerance = 0.02) {
6 return value >= boundaries[0] - tolerance && value <= boundaries[1] + tolerance;
7}
8
10
11 ATH_CHECK(m_cablingKey.initialize());
12 ATH_CHECK(m_scCablingKey.initialize());
13 ATH_CHECK(m_caloSuperCellMgrKey.initialize());
14 ATH_CHECK(m_caloMgrKey.initialize());
15 ATH_CHECK(detStore()->retrieve(m_onlineId, "LArOnlineID"));
16 ATH_CHECK(detStore()->retrieve(m_caloCellId, "CaloCell_ID"));
17 ATH_CHECK(detStore()->retrieve(m_scOnlineId, "LArOnline_SuperCellID"));
18 ATH_CHECK(detStore()->retrieve(m_scCaloCellId, "CaloCell_SuperCell_ID"));
19 ATH_CHECK(m_scidtool.retrieve());
20 return StatusCode::SUCCESS;
21}
22
23StatusCode LArSCIdvsIdTest::execute(const EventContext& ctx) const {
24
26 if (!cablingHdl.isValid()) {
27 ATH_MSG_ERROR("Do not have Onl-Ofl cabling map !!!!");
28 return StatusCode::FAILURE;
29 }
30
32 if (!scCablingHdl.isValid()) {
33 ATH_MSG_ERROR("Do not have Onl-Ofl cabling map for SuperCells !!!!");
34 return StatusCode::FAILURE;
35 }
36
38 if (!scDetMgr.isValid()) {
39 ATH_MSG_ERROR("Do not have CaloSuperCellDetDescrManager !!!!");
40 return StatusCode::FAILURE;
41 }
42
44 if (!detMgr.isValid()) {
45 ATH_MSG_ERROR("Do not have CaloSuperCellDetDescrManager !!!!");
46 return StatusCode::FAILURE;
47 }
48
49 std::bitset<190000> usedIds;
50 for (const HWIdentifier scHWID : m_scOnlineId->channel_range()) {
51 const Identifier scId = scCablingHdl->cnvToIdentifier(scHWID);
52
53 const std::array<int, 3> scReg{m_scCaloCellId->sub_calo(scId), m_scCaloCellId->pos_neg(scId), m_scCaloCellId->calo_sample(scId)};
54 const std::array<int, 3> scFTid{m_scOnlineId->barrel_ec(scHWID), m_scOnlineId->pos_neg(scHWID), m_scOnlineId->feedthrough(scHWID)};
55
56 const CaloDetDescrElement* scDDE = scDetMgr->get_element(scId);
57 const double scEtaRange[2] = {scDDE->eta_raw() - scDDE->deta() / 2.0, scDDE->eta_raw() + scDDE->deta() / 2.0};
58 const double scPhiRange[2] = {scDDE->phi_raw() - scDDE->dphi() / 2.0, scDDE->phi_raw() + scDDE->dphi() / 2.0};
59 const std::vector<Identifier>& regularIDs = m_scidtool->superCellToOfflineID(scId);
60 std::cout << "SuperCell 0x" << std::hex << scId.get_identifier32().get_compact() << " (0x" << scHWID.get_identifier32().get_compact() << std::dec
61 << "), eta=" << scDDE->eta_raw() << ", phi=" << scDDE->phi_raw() << ", sampling=" << m_scCaloCellId->calo_sample(scId) << std::endl;
62 std::cout << "Online " << m_scOnlineId->channel_name(scHWID) << std::endl;
63 for (const Identifier id : regularIDs) {
64 const IdentifierHash hash = m_caloCellId->calo_cell_hash(id);
65 if (usedIds.test(hash)) {
66 ATH_MSG_ERROR("Identifier " << id.get_identifier32().get_compact() << "used in multiple SCs");
67 }
68 usedIds.set(hash);
69 const HWIdentifier hwid = cablingHdl->createSignalChannelIDFromHash(hash);
70 const CaloDetDescrElement* dde = detMgr->get_element(id);
71 std::cout << "\tOnline=" << m_onlineId->channel_name(hwid) << std::endl;
72
73 const int barrel_ec = m_onlineId->barrel_ec(hwid);
74 const int pos_neg = m_onlineId->pos_neg(hwid);
75 int feedthough = m_onlineId->feedthrough(hwid);
76
77 // EMEC IW special-case cabling:
78 if (m_scOnlineId->isEMECIW(scHWID)) {
79 feedthough -= 1;
80 }
81
82 const std::array<int, 3> FTid{barrel_ec, pos_neg, feedthough};
83 if (scFTid != FTid) {
84 ATH_MSG_ERROR("Online FTID mismatch: SC-hwid=" << scFTid << ", hwid=" << FTid);
85 }
86 // int layer=m_layerMap[m_caloCellId->calo_sample(id)];
87 int layer = m_caloCellId->calo_sample(id);
88
89 // Special case: No HEC layers in SC everything labelled HEC0
90 const std::set<CaloSampling::CaloSample> hecSamplings{CaloSampling::HEC1, CaloSampling::HEC2, CaloSampling::HEC3};
91 if (hecSamplings.contains((CaloSampling::CaloSample)layer))
92 layer = CaloSampling::HEC0;
93
94 const std::array<int, 3> reg{m_caloCellId->sub_calo(id), m_caloCellId->pos_neg(id), layer};
95 if (reg != scReg) {
96 ATH_MSG_ERROR("Region id mismatch: SC reg " << scReg << ", reg=" << reg);
97 }
98 std::cout << "\tEta=" << dde->eta_raw() << " Phi=" << dde->phi_raw() << ", sampling=" << layer << std::endl;
99 if (!inRange(scEtaRange, dde->eta_raw(), 0.1)) {
100 ATH_MSG_ERROR("Cell eta=" << dde->eta_raw() << " outside of supercell eta boundaries [" << scEtaRange[0] << "," << scEtaRange[1] << "]");
101 }
102 if (!inRange(scPhiRange, dde->phi_raw())) {
103 ATH_MSG_ERROR("Cell phi=" << dde->phi_raw() << " outside of supercell phi boundaries [" << scPhiRange[0] << "," << scPhiRange[1] << "]");
104 }
105 } // end loop over regular cells connected to this SC
106 } // end loop over supercells
107
108 unsigned nUnused = 0;
109 for (unsigned i = 0; i < m_caloCellId->calo_cell_hash_max(); ++i) {
110 if (!usedIds.test(i)) {
111 const HWIdentifier hwid = cablingHdl->createSignalChannelIDFromHash(i);
112 if (hwid.is_valid()) {
113 ATH_MSG_DEBUG("Regular channel " << m_onlineId->channel_name(hwid) << " is not connected to any SuperCell.");
114 nUnused++;
115 }
116 }
117 }
118 if (nUnused != 128) {
119 ATH_MSG_ERROR("Expected 128 regular cells not connected to any SC, got " << nUnused);
120 }
121
122 return StatusCode::SUCCESS;
123}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
bool inRange(const double *boundaries, const double value, const double tolerance=0.02)
const ServiceHandle< StoreGateSvc > & detStore() const
This class groups all DetDescr information related to a CaloCell.
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
const LArOnline_SuperCellID * m_scOnlineId
ToolHandle< ICaloSuperCellIDTool > m_scidtool
const CaloCell_ID * m_caloCellId
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
const LArOnlineID * m_onlineId
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
const CaloCell_SuperCell_ID * m_scCaloCellId
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
StatusCode execute(const EventContext &ctx) const
SG::ReadCondHandleKey< LArOnOffIdMapping > m_scCablingKey
StatusCode initialize()