ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsAlgs
src
TRTStrawCondAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TRTStrawCondAlg.h
"
6
#include "
TRT_ReadoutGeometry/TRT_BaseElement.h
"
7
8
TRTStrawCondAlg::TRTStrawCondAlg
(
const
std::string& name
9
, ISvcLocator* pSvcLocator )
10
: ::
AthCondAlgorithm
(name, pSvcLocator)
11
{
12
}
13
14
StatusCode
TRTStrawCondAlg::initialize
()
15
{
16
// Straw status
17
ATH_CHECK
(
m_strawStatusSummaryKey
.initialize());
18
19
// Register write handle
20
ATH_CHECK
(
m_strawWriteKey
.initialize());
21
22
// Initialize readCondHandle key
23
ATH_CHECK
(
m_trtDetEleContKey
.initialize());
24
25
// TRT ID helper
26
ATH_CHECK
(
detStore
()->retrieve(
m_trtId
,
"TRT_ID"
));
27
28
return
StatusCode::SUCCESS;
29
}
30
31
StatusCode
TRTStrawCondAlg::execute
(
const
EventContext &ctx)
const
32
{
33
ATH_MSG_DEBUG
(
"execute "
<< name());
34
35
// ____________ Construct Write Cond Handle and check its validity ____________
36
37
SG::WriteCondHandle<TRTCond::AliveStraws>
writeHandle{
m_strawWriteKey
, ctx};
38
39
// Do we have a valid Write Cond Handle for current time?
40
if
(writeHandle.
isValid
()) {
41
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
42
<<
". In theory this should not be called, but may happen"
43
<<
" if multiple concurrent events are being processed out of order."
);
44
45
return
StatusCode::SUCCESS;
46
}
47
48
// Read straw status summary
49
SG::ReadCondHandle<TRTCond::StrawStatusSummary>
strawStatusHandle{
m_strawStatusSummaryKey
, ctx};
50
if
(!strawStatusHandle.
isValid
()){
51
ATH_MSG_FATAL
(
"No access to conditions "
<< strawStatusHandle.
key
());
52
return
StatusCode::FAILURE;
53
}
54
55
EventIDRange range;
56
if
(!strawStatusHandle.
range
(range)){
57
ATH_MSG_ERROR
(
"Failed to get validity range of "
<< strawStatusHandle.
key
());
58
return
StatusCode::FAILURE;
59
}
60
61
ATH_MSG_DEBUG
(
"Retrieved "
<< strawStatusHandle.
key
() <<
" with validity "
<< range);
62
63
const
TRTCond::StrawStatusSummary
*statusSummary = {*strawStatusHandle};
64
if
(statusSummary ==
nullptr
) {
65
ATH_MSG_ERROR
(
"Null pointer to the straw status summary container"
);
66
return
StatusCode::FAILURE;
67
}
68
69
// ____________ Construct new Write Cond Object ____________
70
std::unique_ptr<TRTCond::AliveStraws> writeCdo{std::make_unique<TRTCond::AliveStraws>()};
71
72
SG::ReadCondHandle<InDetDD::TRT_DetElementContainer>
trtDetEleHandle{
m_trtDetEleContKey
, ctx};
73
const
InDetDD::TRT_DetElementCollection
* elements(trtDetEleHandle->getElements());
74
if
(not trtDetEleHandle.
isValid
() or elements==
nullptr
) {
75
ATH_MSG_FATAL
(
m_trtDetEleContKey
.fullKey() <<
" is not available."
);
76
return
StatusCode::FAILURE;
77
}
78
79
// ____________ Compute number of alive straws for Write Cond object ____________
80
81
for
(std::vector<Identifier>::const_iterator it =
m_trtId
->straw_layer_begin(); it !=
m_trtId
->straw_layer_end(); ++it ) {
82
83
// Make sure it is a straw_layer id
84
Identifier
strawLayerId =
m_trtId
->layer_id(*it);
85
//Get hash Id
86
IdentifierHash
hashId =
m_trtId
->straw_layer_hash(strawLayerId);
87
88
unsigned
int
nstraws = 0;
89
if
(trtDetEleHandle.
isValid
()){
90
const
InDetDD::TRT_BaseElement
*el = elements->
getDetectorElement
(hashId);
91
if
( !el )
continue
;
92
nstraws = el->nStraws();
93
}
94
else
{
95
nstraws =
m_trtId
->straw_max( *it) + 1;
// There is a difference of 1 between both methods....
96
}
97
for
(
unsigned
int
i=0; i<nstraws ;i++) {
98
Identifier
id
=
m_trtId
->straw_id( *it, i);
99
int
det =
m_trtId
->barrel_ec(
id
) ;
100
int
lay =
m_trtId
->layer_or_wheel(
id
) ;
101
int
phi
=
m_trtId
->phi_module(
id
) ;
102
bool
status = statusSummary->
findStatus
(
m_trtId
->straw_hash(
id
) );
103
104
if
( status ) {
105
ATH_MSG_VERBOSE
(
" The sector "
<< det <<
" "
<< lay <<
" "
<<
phi
<<
" has status "
<< status);
106
continue
;
107
}
108
109
int
i_total =
findArrayTotalIndex
(det, lay);
110
int
i_wheel =
findArrayLocalWheelIndex
(det, lay);
111
112
writeCdo->update(i_total,i_wheel,
phi
);
113
114
}
115
}
116
117
// Record CDO
118
if
(writeHandle.
record
(range, std::move(writeCdo)).isFailure()) {
119
ATH_MSG_ERROR
(
"Could not record AliveStraws "
<< writeHandle.
key
()
120
<<
" with EventRange "
<< range
121
<<
" into Conditions Store"
);
122
return
StatusCode::FAILURE;
123
}
124
125
return
StatusCode::SUCCESS;
126
}
127
128
int
TRTStrawCondAlg::findArrayTotalIndex
(
const
int
det,
const
int
lay)
const
{
129
int
arrayindex = 0;
// to be reset below
130
// NOTE: Below, arrayindex starts at 1
131
// because index 0 is filled with TOTAL value.
132
if
(det == -1) arrayindex = 1;
// barrel side C
133
else
if
(det == -2) {
// endcap side C
134
if
(lay < 6) arrayindex = 2;
// wheel A
135
else
arrayindex = 3;
// wheel B
136
}
137
else
if
(det == 1) arrayindex = 4;
// barrel side A
138
else
if
(det == 2) {
// endcap side A
139
if
(lay < 6) arrayindex = 5;
// wheel A
140
else
arrayindex = 6;
// wheel B
141
}
142
else
ATH_MSG_WARNING
(
" detector value is: "
<< det <<
", out of range -2, -1, 1, 2, so THIS IS NOT TRT!!!"
);
143
return
arrayindex;
144
}
145
146
int
TRTStrawCondAlg::findArrayLocalWheelIndex
(
const
int
det,
const
int
lay)
const
{
147
int
arrayindex = 9;
// to be reset below
148
if
(det == -1) {
// barrel side C
149
if
(lay == 0) arrayindex = 0;
// layer 0
150
else
if
(lay == 1) arrayindex = 1;
// layer 1
151
else
if
(lay == 2) arrayindex = 2;
// layer 2
152
}
153
else
if
(det == -2) {
// endcap side C
154
for
(
int
i=0; i<14; ++i){
155
if
(lay==i) arrayindex=i+3;
156
}
157
}
158
else
if
(det == 1) {
// barrel side A
159
if
(lay == 0) arrayindex = 17;
// layer 0
160
else
if
(lay == 1) arrayindex = 18;
// layer 1
161
else
if
(lay == 2) arrayindex = 19;
// layer 2
162
}
163
else
if
(det == 2) {
// endcap side A
164
for
(
int
i=0; i<14; ++i){
165
if
(lay==i) arrayindex=i+20;
166
}
167
}
168
else
ATH_MSG_WARNING
(
" detector value is: "
<< det <<
", out of range -2, -1, 1, 2, so THIS IS NOT TRT!!!"
);
169
return
arrayindex;
170
}
171
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
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_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
TRTStrawCondAlg.h
TRT_BaseElement.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
InDetDD::TRT_BaseElement
Virtual base class of TRT readout elements.
Definition
TRT_BaseElement.h:56
InDetDD::TRT_DetElementCollection
Class to hold collection of TRT detector elements.
Definition
TRT_DetElementCollection.h:26
InDetDD::TRT_DetElementCollection::getDetectorElement
const TRT_BaseElement * getDetectorElement(const IdentifierHash &hash) const
Definition
TRT_DetElementCollection.cxx:9
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition
ReadCondHandle.h:223
SG::ReadCondHandle::key
const std::string & key() const
Definition
ReadCondHandle.h:59
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
SG::WriteCondHandle::isValid
bool isValid() const
Definition
WriteCondHandle.h:252
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition
WriteCondHandle.h:45
TRTCond::StrawStatusSummary
Definition
StrawStatusSummary.h:17
TRTCond::StrawStatusSummary::findStatus
bool findStatus(const IdentifierHash &hashID) const
Definition
StrawStatusSummary.cxx:20
TRTStrawCondAlg::m_trtId
const TRT_ID * m_trtId
Definition
TRTStrawCondAlg.h:37
TRTStrawCondAlg::TRTStrawCondAlg
TRTStrawCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TRTStrawCondAlg.cxx:8
TRTStrawCondAlg::findArrayLocalWheelIndex
int findArrayLocalWheelIndex(const int det, const int lay) const
Definition
TRTStrawCondAlg.cxx:146
TRTStrawCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TRTStrawCondAlg.cxx:31
TRTStrawCondAlg::m_strawStatusSummaryKey
SG::ReadCondHandleKey< TRTCond::StrawStatusSummary > m_strawStatusSummaryKey
Definition
TRTStrawCondAlg.h:34
TRTStrawCondAlg::m_trtDetEleContKey
SG::ReadCondHandleKey< InDetDD::TRT_DetElementContainer > m_trtDetEleContKey
Definition
TRTStrawCondAlg.h:33
TRTStrawCondAlg::initialize
virtual StatusCode initialize() override
Definition
TRTStrawCondAlg.cxx:14
TRTStrawCondAlg::m_strawWriteKey
SG::WriteCondHandleKey< TRTCond::AliveStraws > m_strawWriteKey
Definition
TRTStrawCondAlg.h:35
TRTStrawCondAlg::findArrayTotalIndex
int findArrayTotalIndex(const int det, const int lay) const
Definition
TRTStrawCondAlg.cxx:128
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0