ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
BeamSpotConditions
src
BeamSpotCondAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
// BeamSpot_ConditionsAlgs includes
5
#include "
BeamSpotCondAlg.h
"
6
#include "CoralBase/AttributeListException.h"
7
8
const
EventIDRange
BeamSpotCondAlg::alwaysValid
{ EventIDBase { 1,
9
EventIDBase::UNDEFEVT,
10
EventIDBase::UNDEFNUM,
11
EventIDBase::UNDEFNUM,
12
0 },
13
EventIDBase { EventIDBase::UNDEFNUM - 1,
14
EventIDBase::UNDEFEVT,
15
EventIDBase::UNDEFNUM,
16
EventIDBase::UNDEFNUM,
17
EventIDBase::UNDEFNUM - 1 }
18
};
19
20
BeamSpotCondAlg::BeamSpotCondAlg
(
const
std::string& name, ISvcLocator* pSvcLocator )
21
:
AthCondAlgorithm
( name, pSvcLocator )
22
{ }
23
24
25
BeamSpotCondAlg::~BeamSpotCondAlg
() =
default
;
26
27
28
StatusCode
BeamSpotCondAlg::initialize
()
29
{
30
ATH_MSG_DEBUG
(
"Initializing "
<< name() <<
"..."
);
31
32
ATH_CHECK
(
m_readKey
.initialize() );
33
ATH_CHECK
(
m_writeKey
.initialize() );
34
35
return
StatusCode::SUCCESS;
36
}
37
38
StatusCode
BeamSpotCondAlg::execute
(
const
EventContext& ctx)
const
39
{
40
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
"..."
);
41
42
SG::WriteCondHandle<InDet::BeamSpotData>
writeHandle {
m_writeKey
, ctx };
43
if
( writeHandle.
isValid
() )
44
{
45
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid "
<<
46
"Forcing update of Store contents"
);
47
return
StatusCode::SUCCESS;
48
}
49
50
EventIDRange rangeW;
51
InDet::BeamSpotData
* writeCdo =
nullptr
;
52
53
if
( !
m_useDB
)
54
{
55
rangeW =
alwaysValid
;
56
writeCdo =
new
InDet::BeamSpotData
(
m_status
,
m_posX
,
m_posY
,
m_posZ
,
57
m_sigmaX
,
m_sigmaY
,
m_sigmaZ
,
58
m_tiltX
,
m_tiltY
,
m_sigmaXY
);
59
}
60
else
61
{
62
63
SG::ReadCondHandle<AthenaAttributeList>
readHandle {
m_readKey
, ctx };
64
65
const
AthenaAttributeList
* raw { *readHandle };
66
if
( raw ==
nullptr
)
67
{
68
ATH_MSG_ERROR
(
"Beam Spot data for key "
<<
m_readKey
.fullKey() <<
" not found"
);
69
return
StatusCode::FAILURE;
70
}
71
72
int
status { (*raw)[
"status"
].data<
int
>() };
73
float
posX { (*raw)[
"posX"
].data<
float
>() };
74
float
posY { (*raw)[
"posY"
].data<
float
>() };
75
float
posZ { (*raw)[
"posZ"
].data<
float
>() };
76
float
sigmaX { (*raw)[
"sigmaX"
].data<
float
>() };
77
float
sigmaY { (*raw)[
"sigmaY"
].data<
float
>() };
78
float
sigmaZ { (*raw)[
"sigmaZ"
].data<
float
>() };
79
float
tiltX { (*raw)[
"tiltX"
].data<
float
>() };
80
float
tiltY { (*raw)[
"tiltY"
].data<
float
>() };
81
float
sigmaXY {
m_sigmaXY
};
82
try
83
{
84
sigmaXY = (*raw)[
"sigmaXY"
].data<
float
>();
85
}
86
catch
(coral::AttributeListException& e)
87
{
88
ATH_MSG_DEBUG
(
"No sigmaXY value present in database, using default value of "
<< sigmaXY );
89
}
90
91
ATH_MSG_INFO
(
"Read from condDB"
92
<<
" status "
<< status
93
<<
" pos ("
<< posX <<
","
<< posY <<
","
<< posZ <<
")"
94
<<
" sigma ("
<< sigmaX <<
","
<< sigmaY <<
","
<< sigmaZ <<
")"
95
<<
" tilt ("
<< tiltX <<
","
<< tiltY <<
")"
96
<<
" sigmaXY "
<< sigmaXY );
97
98
if
( !readHandle.
range
(rangeW) )
99
{
100
ATH_MSG_ERROR
(
"Failed to retrieve validity range for "
<< readHandle.
key
() );
101
return
StatusCode::FAILURE;
102
}
103
104
writeCdo =
new
InDet::BeamSpotData
( status, posX, posY, posZ,
105
sigmaX, sigmaY, sigmaZ,
106
tiltX, tiltY, sigmaXY );
107
}
108
109
if
( writeHandle.
record
( rangeW, writeCdo ).isFailure() )
110
{
111
ATH_MSG_ERROR
(
"Could not record InDet::BeamSpotData "
<< writeHandle.
key
() <<
112
" with EventRange "
<< rangeW <<
" into conditions store."
);
113
return
StatusCode::FAILURE;
114
}
115
116
ATH_MSG_INFO
(
"Recorded new InDet::BeamSpotData to "
<< writeHandle.
key
() <<
" with range "
<< rangeW <<
117
" into conditions store."
);
118
119
return
StatusCode::SUCCESS;
120
}
121
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_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
BeamSpotCondAlg.h
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
BeamSpotCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
BeamSpotCondAlg.cxx:38
BeamSpotCondAlg::m_tiltX
Gaudi::Property< float > m_tiltX
Definition
BeamSpotCondAlg.h:44
BeamSpotCondAlg::m_posY
Gaudi::Property< float > m_posY
Definition
BeamSpotCondAlg.h:39
BeamSpotCondAlg::m_sigmaY
Gaudi::Property< float > m_sigmaY
Definition
BeamSpotCondAlg.h:42
BeamSpotCondAlg::m_sigmaXY
Gaudi::Property< float > m_sigmaXY
Definition
BeamSpotCondAlg.h:46
BeamSpotCondAlg::m_status
Gaudi::Property< int > m_status
Definition
BeamSpotCondAlg.h:37
BeamSpotCondAlg::m_sigmaX
Gaudi::Property< float > m_sigmaX
Definition
BeamSpotCondAlg.h:41
BeamSpotCondAlg::m_posZ
Gaudi::Property< float > m_posZ
Definition
BeamSpotCondAlg.h:40
BeamSpotCondAlg::m_tiltY
Gaudi::Property< float > m_tiltY
Definition
BeamSpotCondAlg.h:45
BeamSpotCondAlg::m_writeKey
SG::WriteCondHandleKey< InDet::BeamSpotData > m_writeKey
Definition
BeamSpotCondAlg.h:33
BeamSpotCondAlg::~BeamSpotCondAlg
virtual ~BeamSpotCondAlg()
BeamSpotCondAlg::BeamSpotCondAlg
BeamSpotCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
BeamSpotCondAlg.cxx:20
BeamSpotCondAlg::alwaysValid
static const EventIDRange alwaysValid
Definition
BeamSpotCondAlg.h:8
BeamSpotCondAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition
BeamSpotCondAlg.h:30
BeamSpotCondAlg::m_useDB
Gaudi::Property< bool > m_useDB
Definition
BeamSpotCondAlg.h:36
BeamSpotCondAlg::m_posX
Gaudi::Property< float > m_posX
Definition
BeamSpotCondAlg.h:38
BeamSpotCondAlg::initialize
virtual StatusCode initialize() override final
Definition
BeamSpotCondAlg.cxx:28
BeamSpotCondAlg::m_sigmaZ
Gaudi::Property< float > m_sigmaZ
Definition
BeamSpotCondAlg.h:43
InDet::BeamSpotData
Definition
BeamSpotData.h:21
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::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
Generated on
for ATLAS Offline Software by
1.17.0