ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecTools
SiDetElementsRoadTool_xk
src
SiDetElementsRoadCondAlg_xk.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
SiDetElementsRoadCondAlg_xk.h
"
6
7
#include "
SiDetElementsRoadUtils_xk.h
"
8
9
#include "
SiDetElementsRoadTool_xk/SiDetElementsComparison.h
"
10
#include "
SiDetElementsRoadTool_xk/SiDetElementsLayer_xk.h
"
11
12
#include <memory>
13
#include <utility>
14
16
// Constructor
18
19
InDet::SiDetElementsRoadCondAlg_xk::SiDetElementsRoadCondAlg_xk
(
const
std::string& name, ISvcLocator* pSvcLocator)
20
: ::
AthCondAlgorithm
(name, pSvcLocator)
21
{
22
}
23
25
// Initialisation
27
28
StatusCode
InDet::SiDetElementsRoadCondAlg_xk::initialize
()
29
{
30
if
((not
m_usePIX
) and (not
m_useSCT
)) {
31
ATH_MSG_FATAL
(
"Please don't call this tool if usePixel and useSCT are false"
);
32
return
StatusCode::FAILURE;
33
}
34
35
ATH_CHECK
(
m_pixelDetEleCollKey
.initialize(
m_usePIX
));
36
ATH_CHECK
(
m_SCTDetEleCollKey
.initialize(
m_useSCT
));
37
38
ATH_CHECK
(
m_writeKey
.initialize());
39
40
return
StatusCode::SUCCESS;
41
}
42
44
// Finalize
46
47
StatusCode
InDet::SiDetElementsRoadCondAlg_xk::finalize
()
48
{
49
return
StatusCode::SUCCESS;
50
}
51
53
// Map of detector elements production
54
// Taken from InDet::SiDetElementsRoadMaker_xk::mapDetectorElementsProduction()
56
57
StatusCode
InDet::SiDetElementsRoadCondAlg_xk::execute
(
const
EventContext& ctx)
const
58
{
59
const
double
pi2=2.*
M_PI
;
60
const
double
pi
=
M_PI
;
61
62
SG::WriteCondHandle<SiDetElementsLayerVectors_xk>
writeHandle{
m_writeKey
, ctx};
63
if
(writeHandle.
isValid
()) {
64
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
65
<<
". In theory this should not be called, but may happen"
66
<<
" if multiple concurrent events are being processed out of order."
);
67
return
StatusCode::SUCCESS;
68
}
69
70
std::unique_ptr<SiDetElementsLayerVectors_xk> writeCdo{std::make_unique<SiDetElementsLayerVectors_xk>(3)};
71
72
std::vector<const InDetDD::SiDetectorElement*> pW[3];
73
74
if
(
m_usePIX
) {
75
// Loop over each wafer of pixels
76
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
pixelDetEleHandle(
m_pixelDetEleCollKey
, ctx);
77
const
InDetDD::SiDetectorElementCollection
* pixelDetEle{*pixelDetEleHandle};
78
if
(not pixelDetEleHandle.
isValid
() or pixelDetEle==
nullptr
) {
79
ATH_MSG_FATAL
(
m_pixelDetEleCollKey
.fullKey() <<
" is not available."
);
80
return
StatusCode::FAILURE;
81
}
82
for
(
const
InDetDD::SiDetectorElement
* s: *pixelDetEle) {
83
if
(s->isBarrel() ) pW[1].push_back(s);
// Barrel
84
else
if
(s->center().z() > 0.) pW[2].push_back(s);
// Right endcap
85
else
pW[0].push_back(s);
// Left endcap
86
}
87
88
writeHandle.
addDependency
(pixelDetEleHandle);
89
}
90
91
if
(
m_useSCT
) {
92
// Loop over each wafer of sct
93
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
sctDetEleHandle(
m_SCTDetEleCollKey
, ctx);
94
const
InDetDD::SiDetectorElementCollection
* sctDetEle{*sctDetEleHandle};
95
if
(not sctDetEleHandle.
isValid
() or sctDetEle==
nullptr
) {
96
ATH_MSG_FATAL
(
m_SCTDetEleCollKey
.fullKey() <<
" is not available."
);
97
return
StatusCode::FAILURE;
98
}
99
for
(
const
InDetDD::SiDetectorElement
* s: *sctDetEle) {
100
if
(s->isBarrel() ) pW[1].push_back(s);
// Barrel
101
else
if
(s->center().z() > 0.) pW[2].push_back(s);
// Right endcap
102
else
pW[0].push_back(s);
// Left endcap
103
}
104
105
writeHandle.
addDependency
(sctDetEleHandle);
106
}
107
108
int
nel = pW[0].size()+pW[1].size()+pW[2].size();
109
if
(nel==0) {
110
ATH_MSG_WARNING
(
"The number of elements is zero."
);
111
return
StatusCode::SUCCESS;
112
}
113
114
std::sort
(pW[1].begin(), pW[1].end(),
InDet::compDetElements_RAZ
());
115
std::sort
(pW[0].begin(), pW[0].end(),
InDet::compDetElements_ZRA
());
116
std::sort
(pW[2].begin(), pW[2].end(),
InDet::compDetElements_ZRA
());
117
118
for
(
int
N=0; N<3; ++N) {
119
120
double
P
[40];
121
int
im =
static_cast<
int
>
(pW[N].size())-1;
122
int
If = 0 ;
123
double
z0 = 0. ;
124
double
r0 = 0. ;
125
126
for
(
int
i = 0; i<= im; ++i) {
127
128
InDet::SiDetElementsRoadUtils_xk::detElementInformation
(*(pW[N][i]),
P
);
129
130
double
r
=
P
[0];
131
double
z
=
P
[1];
132
bool
newl =
false
;
133
if
(N==1) {
134
if
(fabs(
r
-r0) > 10.) {
135
newl=
true
;
136
r0=
r
;
137
}
138
}
else
{
139
if
(fabs(
z
-z0) > 10.) {
140
newl=
true
;
141
r0=
r
;
142
z0=
z
;
143
}
144
}
145
146
if
(newl || i==im) {
147
148
int
Il = i-1;
149
if
(i==im) ++Il;
150
151
if
(If<=Il) {
152
153
double
rmin = 100000., rmax =-100000.;
154
double
zmin = 100000., zmax =-100000.;
155
double
dfm = 0.;
156
157
std::vector<const InDetDD::SiDetectorElement*> pE;
158
for
(
int
j=If; j<=Il; ++j) pE.push_back(pW[N][j]);
159
std::sort
(pE.begin(), pE.end(),
InDet::compDetElements_A
());
160
161
InDet::SiDetElementsLayer_xk
layer;
162
163
for
(
auto
& j : pE) {
164
165
if
(j) {
166
167
InDet::SiDetElementsRoadUtils_xk::detElementInformation
(*j,
P
);
168
169
if
(
P
[ 9] < rmin ) rmin =
P
[ 9];
170
if
(
P
[10] > rmax ) rmax =
P
[10];
171
if
(
P
[11] < zmin ) zmin =
P
[11];
172
if
(
P
[12] > zmax ) zmax =
P
[12];
173
174
double
df1 = fabs(
P
[13]-
P
[2]);
175
if
(df1>
pi
) df1 = fabs(df1-pi2);
176
double
df2 = fabs(
P
[14]-
P
[2]);
177
if
(df2>
pi
) df2 = fabs(df2-pi2);
178
if
(df1>dfm) dfm = df1;
179
if
(df2>dfm) dfm = df2;
180
181
InDet::SiDetElementLink_xk
link(j,
P
,
m_ITkGeometry
);
182
layer.add(link);
183
}
184
}
185
layer.sortDetectorElements();
186
double
r
=(rmax+rmin)*.5;
187
double
dr =(rmax-rmin)*.5;
188
double
z
=(zmax+zmin)*.5;
189
double
dz =(zmax-zmin)*.5;
190
layer.set(
r
, dr,
z
, dz, dfm);
191
(writeCdo->at(N)).push_back(std::move(layer));
192
}
193
If = i;
194
}
195
}
196
}
197
198
if
(writeHandle.
record
(std::move(writeCdo)).isFailure()) {
199
ATH_MSG_FATAL
(
"Could not record "
<< writeHandle.
key
()
200
<<
" with EventRange "
<< writeHandle.
getRange
()
201
<<
" into Conditions Store"
);
202
return
StatusCode::FAILURE;
203
}
204
ATH_MSG_DEBUG
(
"recorded new CDO "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
() <<
" into Conditions Store"
);
205
206
return
StatusCode::SUCCESS;
207
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
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
P
static Double_t P(Double_t *tt, Double_t *par)
Definition
LArPhysWaveHECTool.cxx:280
SiDetElementsComparison.h
SiDetElementsLayer_xk.h
SiDetElementsRoadCondAlg_xk.h
SiDetElementsRoadUtils_xk.h
pi
#define pi
Definition
TileMuonFitter.cxx:65
z
#define z
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
InDetDD::SiDetectorElementCollection
Class to hold the SiDetectorElement objects to be put in the detector store.
Definition
SiDetectorElementCollection.h:27
InDetDD::SiDetectorElement
Class to hold geometrical description of a silicon detector element.
Definition
SiDetectorElement.h:109
InDet::SiDetElementLink_xk
Definition
SiDetElementLink_xk.h:24
InDet::SiDetElementsLayer_xk
Definition
SiDetElementsLayer_xk.h:28
InDet::SiDetElementsRoadCondAlg_xk::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
SiDetElementsRoadCondAlg_xk.cxx:57
InDet::SiDetElementsRoadCondAlg_xk::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition
SiDetElementsRoadCondAlg_xk.h:77
InDet::SiDetElementsRoadCondAlg_xk::SiDetElementsRoadCondAlg_xk
SiDetElementsRoadCondAlg_xk(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SiDetElementsRoadCondAlg_xk.cxx:19
InDet::SiDetElementsRoadCondAlg_xk::m_writeKey
SG::WriteCondHandleKey< SiDetElementsLayerVectors_xk > m_writeKey
Definition
SiDetElementsRoadCondAlg_xk.h:78
InDet::SiDetElementsRoadCondAlg_xk::initialize
virtual StatusCode initialize() override
Definition
SiDetElementsRoadCondAlg_xk.cxx:28
InDet::SiDetElementsRoadCondAlg_xk::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition
SiDetElementsRoadCondAlg_xk.h:76
InDet::SiDetElementsRoadCondAlg_xk::m_useSCT
BooleanProperty m_useSCT
Definition
SiDetElementsRoadCondAlg_xk.h:67
InDet::SiDetElementsRoadCondAlg_xk::m_usePIX
BooleanProperty m_usePIX
Definition
SiDetElementsRoadCondAlg_xk.h:66
InDet::SiDetElementsRoadCondAlg_xk::m_ITkGeometry
BooleanProperty m_ITkGeometry
Definition
SiDetElementsRoadCondAlg_xk.h:68
InDet::SiDetElementsRoadCondAlg_xk::finalize
virtual StatusCode finalize() override
Definition
SiDetElementsRoadCondAlg_xk.cxx:47
InDet::compDetElements_A
Definition
SiDetElementsComparison.h:16
InDet::compDetElements_RAZ
Definition
SiDetElementsComparison.h:37
InDet::compDetElements_ZRA
Definition
SiDetElementsComparison.h:62
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
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::addDependency
void addDependency(const EventIDRange &range)
Definition
WriteCondHandle.h:279
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition
WriteCondHandle.h:93
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
r
int r
Definition
globals.cxx:22
InDet::SiDetElementsRoadUtils_xk::detElementInformation
void detElementInformation(const InDetDD::SiDetectorElement &Si, double *P)
Definition
SiDetElementsRoadUtils_xk.cxx:42
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
Generated on
for ATLAS Offline Software by
1.17.0