ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsServices
src
TRT_ConditionsSummarySvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
10
11
#include "
TRT_ConditionsSummarySvc.h
"
12
#include "
TRT_ReadoutGeometry/TRT_BaseElement.h
"
13
#include "
InDetConditionsSummaryService/InDetHierarchy.h
"
14
#include "
InDetIdentifier/TRT_ID.h
"
15
#include "
TRT_ReadoutGeometry/TRT_DetectorManager.h
"
16
17
//Gaudi includes
18
#include "
StoreGate/StoreGateSvc.h
"
19
20
// Constructor
21
TRT_ConditionsSummarySvc::TRT_ConditionsSummarySvc
(
const
std::string& name, ISvcLocator* pSvcLocator ) :
22
base_class(name, pSvcLocator),
23
m_svcCollection
(name)
24
{
25
// Get properties from job options
26
declareProperty(
"ServiceList"
,
m_svcCollection
);
27
}
28
29
// Destructor
30
TRT_ConditionsSummarySvc::~TRT_ConditionsSummarySvc
()=
default
;
31
32
//Initialize
33
StatusCode
34
TRT_ConditionsSummarySvc::initialize
(){
35
ATH_MSG_DEBUG
(
"TRT_ConditionsSummarySvc::initialize."
);
36
37
// Retrieve the services to be called.
38
if
(
m_svcCollection
.empty() ) {
39
ATH_MSG_WARNING
(
"No services to be called!"
);
40
}
else
{
41
ATH_CHECK
(
m_svcCollection
.retrieve());
42
ATH_MSG_DEBUG
(
"Successfully retrieved services: "
<<
m_svcCollection
);
43
}
44
45
// Get DetectorStore service
46
SmartIF<StoreGateSvc> detStore{service(
"DetectorStore"
)};
47
ATH_CHECK
( detStore.isValid() );
48
49
// Retrieve TRT_DetectorManager
50
ATH_CHECK
(detStore->retrieve(
m_manager
,
"TRT"
));
51
52
// Retrieve TRT ID Helper
53
ATH_CHECK
(detStore->retrieve(
m_trtid
,
"TRT_ID"
));
54
55
return
StatusCode::SUCCESS;
56
}
57
58
bool
59
TRT_ConditionsSummarySvc::isActive
(
const
Identifier
& elementId,
const
InDetConditions::Hierarchy
h
){
60
bool
result(
false
);
61
62
if
(
h
==
InDetConditions::TRT_STRAW
||
h
==
InDetConditions::DEFAULT
){
63
InDet::TRT_CondFlag flag=
condSummaryStatus
(elementId);
64
65
result = flag==InDet::TRT_COND_GOOD || flag==InDet::TRT_COND_CAUTION || flag==InDet::TRT_COND_NOINFO;
66
}
else
if
(
h
==
InDetConditions::TRT_STRAW_LAYER
){
67
//need to loop over all straws at this hierarchy level
68
result=
true
;
69
const
InDetDD::TRT_BaseElement
*element=
m_manager
->getElement(elementId);
70
71
//loop over all straws
72
int
nelements=element->
nStraws
();
73
for
(
int
i=0;i<nelements;i++){
74
InDet::TRT_CondFlag flag=
condSummaryStatus
(
m_trtid
->straw_id(elementId,i));
75
if
(!(flag==InDet::TRT_COND_GOOD || flag==InDet::TRT_COND_CAUTION || flag==InDet::TRT_COND_NOINFO)){
76
result=
false
;
77
break
;
78
}
79
}
80
}
else
{
81
ATH_MSG_FATAL
(
"Hierarchy Level "
<<
h
<<
" not yet implemented!!!"
);
82
result=
false
;
83
}
84
85
return
result;
86
}
87
88
bool
89
TRT_ConditionsSummarySvc::isActive
(
const
IdentifierHash
& elementHash){
90
bool
result(
true
);
91
92
const
InDetDD::TRT_BaseElement
*element=
m_manager
->getElement(elementHash);
93
94
Identifier
elementId=
m_trtid
->layer_id(elementHash);
95
96
//loop over all straws
97
int
nelements=element->
nStraws
();
98
for
(
int
i=0;i<nelements;i++){
99
InDet::TRT_CondFlag flag=
condSummaryStatus
(
m_trtid
->straw_id(elementId,i));
100
if
(!(flag==InDet::TRT_COND_GOOD || flag==InDet::TRT_COND_CAUTION || flag==InDet::TRT_COND_NOINFO)){
101
result=
false
;
102
break
;
103
}
104
}
105
106
return
result;
107
}
108
109
bool
110
TRT_ConditionsSummarySvc::isActive
(
const
IdentifierHash
&,
const
Identifier
& elementId){
111
bool
result(
false
);
112
113
result=
isActive
(elementId,
InDetConditions::TRT_STRAW
);
114
115
return
result;
116
}
117
118
double
119
TRT_ConditionsSummarySvc::activeFraction
(
const
IdentifierHash
& elementHash,
const
Identifier
& idStart,
const
Identifier
& idEnd){
120
double
result(0.0);
121
122
Identifier
layerId=
m_trtid
->layer_id(elementHash);
123
124
int
start=
m_trtid
->straw(idStart);
125
int
end=
m_trtid
->straw(idEnd);
126
127
double
count
=1.0;
128
for
(
int
i=start;i<=end;i++){
129
Identifier
elementId=
m_trtid
->straw_id(layerId,i);
130
if
(
isActive
(elementId,
InDetConditions::TRT_STRAW
))
131
result+=1.0;
132
}
133
if
(
count
>0){
134
result/=
count
;
135
}
136
137
return
result;
138
}
139
140
bool
141
TRT_ConditionsSummarySvc::isGood
(
const
Identifier
& elementId,
const
InDetConditions::Hierarchy
h
){
142
bool
result(
false
);
143
144
if
(
h
==
InDetConditions::TRT_STRAW
||
h
==
InDetConditions::DEFAULT
){
145
InDet::TRT_CondFlag flag=
condSummaryStatus
(elementId);
146
147
result = flag==InDet::TRT_COND_GOOD;
148
}
else
if
(
h
==
InDetConditions::TRT_STRAW_LAYER
){
149
//need to loop over all straws at this hierarchy level
150
result=
true
;
151
const
InDetDD::TRT_BaseElement
*element=
m_manager
->getElement(elementId);
152
153
//loop over all straws
154
int
nelements=element->
nStraws
();
155
for
(
int
i=0;i<nelements;i++){
156
InDet::TRT_CondFlag flag=
condSummaryStatus
(
m_trtid
->straw_id(elementId,i));
157
if
(!(flag==InDet::TRT_COND_GOOD)){
158
result=
false
;
159
break
;
160
}
161
}
162
}
else
{
163
ATH_MSG_FATAL
(
"Hierarchy Level "
<<
h
<<
" not yet implemented!!!"
);
164
result=
false
;
165
}
166
167
return
result;
168
}
169
170
bool
171
TRT_ConditionsSummarySvc::isGood
(
const
IdentifierHash
& elementHash){
172
bool
result(
false
);
173
174
const
InDetDD::TRT_BaseElement
*element=
m_manager
->getElement(elementHash);
175
176
Identifier
elementId=
m_trtid
->layer_id(elementHash);
177
178
//loop over all straws
179
int
nelements=element->
nStraws
();
180
for
(
int
i=0;i<nelements;i++){
181
InDet::TRT_CondFlag flag=
condSummaryStatus
(
m_trtid
->straw_id(elementId,i));
182
if
(!(flag==InDet::TRT_COND_GOOD)){
183
result=
false
;
184
break
;
185
}
186
}
187
188
return
result;
189
}
190
191
bool
192
TRT_ConditionsSummarySvc::isGood
(
const
IdentifierHash
&,
const
Identifier
& elementId){
193
bool
result(
false
);
194
195
result=
isGood
(elementId,
InDetConditions::TRT_STRAW
);
196
197
return
result;
198
}
199
200
double
201
TRT_ConditionsSummarySvc::goodFraction
(
const
IdentifierHash
& elementHash,
const
Identifier
& idStart,
const
Identifier
& idEnd){
202
double
result(0.0);
203
204
Identifier
layerId=
m_trtid
->layer_id(elementHash);
205
206
int
start=
m_trtid
->straw(idStart);
207
int
end=
m_trtid
->straw(idEnd);
208
209
double
count
=1.0;
210
for
(
int
i=start;i<=end;i++){
211
Identifier
elementId=
m_trtid
->straw_id(layerId,i);
212
if
(
isGood
(elementId,
InDetConditions::TRT_STRAW
))
213
result+=1.0;
214
}
215
if
(
count
>0){
216
result/=
count
;
217
}
218
219
return
result;
220
}
221
222
InDet::TRT_CondFlag
223
TRT_ConditionsSummarySvc::condSummaryStatus
(
const
Identifier
&ident ) {
224
225
// Identifier id=ident;
226
InDet::TRT_CondFlag status = InDet::TRT_COND_GOOD;
227
228
// Call condSummaryStatus for each service in m_svcCollection.
229
ServiceHandleArray<ITRT_ConditionsSvc>::const_iterator svcItr;
230
for
( svcItr =
m_svcCollection
.begin();
231
svcItr !=
m_svcCollection
.end(); ++svcItr ) {
232
InDet::TRT_CondFlag thisSvcFlag;
233
thisSvcFlag = (*svcItr)->condSummaryStatus( ident );
234
if
( thisSvcFlag == InDet::TRT_COND_SKIPME )
continue
;
235
if
( thisSvcFlag == InDet::TRT_COND_NOINFO )
continue
;
236
// If any tool reports CAUTION, return CAUTION.
237
// If any tool reports BAD, return BAD.
238
if
( thisSvcFlag != InDet::TRT_COND_GOOD ) {
239
if
( status != InDet::TRT_COND_BAD ) status = InDet::TRT_COND_CAUTION;
240
if
( thisSvcFlag == InDet::TRT_COND_BAD ) status = InDet::TRT_COND_BAD;
241
}
242
}
243
244
return
status;
245
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
InDetHierarchy.h
Header containing the InDetHierarchy enum, to avoid pulling in a class every time it is needed and na...
StoreGateSvc.h
TRT_BaseElement.h
TRT_ConditionsSummarySvc.h
TRT_DetectorManager.h
TRT_ID.h
This is an Identifier helper class for the TRT subdetector.
h
Header file for AthHistogramAlgorithm.
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_BaseElement::nStraws
unsigned int nStraws() const
Number of straws in the element.
TRT_ConditionsSummarySvc::condSummaryStatus
InDet::TRT_CondFlag condSummaryStatus(const Identifier &ident)
Definition
TRT_ConditionsSummarySvc.cxx:223
TRT_ConditionsSummarySvc::m_manager
const InDetDD::TRT_DetectorManager * m_manager
Definition
TRT_ConditionsSummarySvc.h:65
TRT_ConditionsSummarySvc::initialize
virtual StatusCode initialize() override
Service init.
Definition
TRT_ConditionsSummarySvc.cxx:34
TRT_ConditionsSummarySvc::m_trtid
const TRT_ID * m_trtid
Definition
TRT_ConditionsSummarySvc.h:66
TRT_ConditionsSummarySvc::goodFraction
virtual double goodFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd) override
Definition
TRT_ConditionsSummarySvc.cxx:201
TRT_ConditionsSummarySvc::TRT_ConditionsSummarySvc
TRT_ConditionsSummarySvc(const std::string &name, ISvcLocator *svc)
Service constructor.
Definition
TRT_ConditionsSummarySvc.cxx:21
TRT_ConditionsSummarySvc::isActive
virtual bool isActive(const Identifier &elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) override
Definition
TRT_ConditionsSummarySvc.cxx:59
TRT_ConditionsSummarySvc::~TRT_ConditionsSummarySvc
virtual ~TRT_ConditionsSummarySvc()
TRT_ConditionsSummarySvc::isGood
virtual bool isGood(const Identifier &elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) override
Definition
TRT_ConditionsSummarySvc.cxx:141
TRT_ConditionsSummarySvc::m_svcCollection
ServiceHandleArray< ITRT_ConditionsSvc > m_svcCollection
Definition
TRT_ConditionsSummarySvc.h:62
TRT_ConditionsSummarySvc::activeFraction
virtual double activeFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd) override
Definition
TRT_ConditionsSummarySvc.cxx:119
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
Identifier
Definition
IdentifierFieldParser.cxx:14
InDetConditions::Hierarchy
Hierarchy
Definition
InDetHierarchy.h:14
InDetConditions::TRT_STRAW_LAYER
@ TRT_STRAW_LAYER
Definition
InDetHierarchy.h:16
InDetConditions::TRT_STRAW
@ TRT_STRAW
Definition
InDetHierarchy.h:16
InDetConditions::DEFAULT
@ DEFAULT
Definition
InDetHierarchy.h:14
Generated on
for ATLAS Offline Software by
1.17.0