ATLAS Offline Software
LArSCIdVsIdTest.cxx
Go to the documentation of this file.
1 #include "LArSCIdVsIdTest.h"
2 
3 #include "CaloDetDescr/CaloDetDescrElement.h"
4 
5 bool 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 
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 
23 StatusCode 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) {
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))
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 }
CaloDetDescrElement::deta
float deta() const
cell deta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArOnOffIdMapping::createSignalChannelIDFromHash
HWIdentifier createSignalChannelIDFromHash(const IdentifierHash &id_hash) const
create a HWIdentifier from an Identifier (from hash) (inline)
Definition: LArOnOffIdMapping.h:104
LArSCIdvsIdTest::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArSCIdVsIdTest.h:31
LArSCIdvsIdTest::initialize
StatusCode initialize()
Definition: LArSCIdVsIdTest.cxx:9
tolerance
constexpr double tolerance
Definition: runMdtGeoComparison.cxx:104
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
LArSCIdVsIdTest.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LArSCIdvsIdTest::m_caloCellId
const CaloCell_ID * m_caloCellId
Definition: LArSCIdVsIdTest.h:38
LArOnline_SuperCellID::isEMECIW
bool isEMECIW(const HWIdentifier id) const override final
Definition: LArOnline_SuperCellID.cxx:376
LArSCIdvsIdTest::m_caloSuperCellMgrKey
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
Definition: LArSCIdVsIdTest.h:33
CaloCell_Base_ID::pos_neg
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArSCIdvsIdTest::m_scCaloCellId
const CaloCell_SuperCell_ID * m_scCaloCellId
Definition: LArSCIdVsIdTest.h:41
athena.value
value
Definition: athena.py:124
CaloCell_ID_FCS::HEC2
@ HEC2
Definition: FastCaloSim_CaloCell_ID.h:29
CaloCell_Base_ID::calo_sample
int calo_sample(const Identifier id) const
returns an int taken from Sampling enum and describing the subCalo to which the Id belongs.
Definition: CaloCell_Base_ID.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
LArOnlineID_Base::barrel_ec
int barrel_ec(const HWIdentifier id) const
Return the position barrel or endcap of a hardware cell identifier: barrel_ec = [0,...
Definition: LArOnlineID_Base.cxx:1938
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
LArSCIdvsIdTest::m_scidtool
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Definition: LArSCIdVsIdTest.h:36
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArSCIdvsIdTest::execute
StatusCode execute(const EventContext &ctx) const
Definition: LArSCIdVsIdTest.cxx:23
CaloCell_ID_FCS::HEC1
@ HEC1
Definition: FastCaloSim_CaloCell_ID.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOnlineID_Base::channel_range
id_range channel_range() const
Definition: LArOnlineID_Base.cxx:1932
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
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
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LArOnlineID_Base::pos_neg
int pos_neg(const HWIdentifier id) const
Return the side of a hardware cell identifier pos_neg = [0,1] positive-side or negative-side Barrel...
Definition: LArOnlineID_Base.cxx:1950
CaloCell_Base_ID::sub_calo
int sub_calo(const Identifier id) const
returns an int taken from SUBCALO enum and describing the subCalo to which the Id belongs.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArSCIdvsIdTest::m_scOnlineId
const LArOnline_SuperCellID * m_scOnlineId
Definition: LArSCIdVsIdTest.h:40
inRange
bool inRange(const double *boundaries, const double value, const double tolerance=0.02)
Definition: LArSCIdVsIdTest.cxx:5
tolerance
Definition: suep_shower.h:17
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCell_ID_FCS::HEC0
@ HEC0
Definition: FastCaloSim_CaloCell_ID.h:27
LArSCIdvsIdTest::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: LArSCIdVsIdTest.h:34
CaloDetDescrElement::dphi
float dphi() const
cell dphi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:358
LArSCIdvsIdTest::m_onlineId
const LArOnlineID * m_onlineId
Definition: LArSCIdVsIdTest.h:37
LArOnlineID_Base::feedthrough
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
Definition: LArOnlineID_Base.cxx:1944
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
LArOnOffIdMapping::cnvToIdentifier
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
Definition: LArOnOffIdMapping.h:116
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloCell_ID_FCS::HEC3
@ HEC3
Definition: FastCaloSim_CaloCell_ID.h:30
LArOnlineID_Base::channel_name
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
Definition: LArOnlineID_Base.cxx:219
LArSCIdvsIdTest::m_scCablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_scCablingKey
Definition: LArSCIdVsIdTest.h:32
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
Identifier
Definition: IdentifierFieldParser.cxx:14