ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArTest
LArConditionsTest
src
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
9
StatusCode
LArSCIdvsIdTest::initialize
() {
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
23
StatusCode
LArSCIdvsIdTest::execute
(
const
EventContext& ctx)
const
{
24
25
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl(
m_cablingKey
, ctx);
26
if
(!cablingHdl.
isValid
()) {
27
ATH_MSG_ERROR
(
"Do not have Onl-Ofl cabling map !!!!"
);
28
return
StatusCode::FAILURE;
29
}
30
31
SG::ReadCondHandle<LArOnOffIdMapping>
scCablingHdl(
m_scCablingKey
, ctx);
32
if
(!scCablingHdl.
isValid
()) {
33
ATH_MSG_ERROR
(
"Do not have Onl-Ofl cabling map for SuperCells !!!!"
);
34
return
StatusCode::FAILURE;
35
}
36
37
SG::ReadCondHandle<CaloSuperCellDetDescrManager>
scDetMgr(
m_caloSuperCellMgrKey
, ctx);
38
if
(!scDetMgr.
isValid
()) {
39
ATH_MSG_ERROR
(
"Do not have CaloSuperCellDetDescrManager !!!!"
);
40
return
StatusCode::FAILURE;
41
}
42
43
SG::ReadCondHandle<CaloDetDescrManager>
detMgr(
m_caloMgrKey
, ctx);
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
inRange
bool inRange(const double *boundaries, const double value, const double tolerance=0.02)
Definition
LArSCIdVsIdTest.cxx:5
LArSCIdVsIdTest.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell.
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
CaloDetDescrElement::dphi
float dphi() const
cell dphi
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:358
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352
CaloDetDescrElement::deta
float deta() const
cell deta
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
CaloSampling::CaloSample
CaloSample
Definition
Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
HWIdentifier
Definition
HWIdentifier.h:13
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition
Identifier32.h:47
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArSCIdvsIdTest::m_scOnlineId
const LArOnline_SuperCellID * m_scOnlineId
Definition
LArSCIdVsIdTest.h:40
LArSCIdvsIdTest::m_scidtool
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Definition
LArSCIdVsIdTest.h:36
LArSCIdvsIdTest::m_caloCellId
const CaloCell_ID * m_caloCellId
Definition
LArSCIdVsIdTest.h:38
LArSCIdvsIdTest::m_caloSuperCellMgrKey
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
Definition
LArSCIdVsIdTest.h:33
LArSCIdvsIdTest::m_onlineId
const LArOnlineID * m_onlineId
Definition
LArSCIdVsIdTest.h:37
LArSCIdvsIdTest::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition
LArSCIdVsIdTest.h:31
LArSCIdvsIdTest::m_scCaloCellId
const CaloCell_SuperCell_ID * m_scCaloCellId
Definition
LArSCIdVsIdTest.h:41
LArSCIdvsIdTest::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition
LArSCIdVsIdTest.h:34
LArSCIdvsIdTest::execute
StatusCode execute(const EventContext &ctx) const
Definition
LArSCIdVsIdTest.cxx:23
LArSCIdvsIdTest::m_scCablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_scCablingKey
Definition
LArSCIdVsIdTest.h:32
LArSCIdvsIdTest::initialize
StatusCode initialize()
Definition
LArSCIdVsIdTest.cxx:9
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
tolerance
Definition
suep_shower.h:17
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0