ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
CoolLumiUtilities
src
Database/CoolLumiUtilities/src/BunchGroupCondAlg.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
12
#include "
BunchGroupCondAlg.h
"
13
#include "
StoreGate/ReadCondHandle.h
"
14
#include "
StoreGate/WriteCondHandle.h
"
15
#include "CoralBase/Blob.h"
16
#include "CoolKernel/IObject.h"
17
#include <stdint.h>
18
19
23
StatusCode
24
BunchGroupCondAlg::initialize
()
25
{
26
ATH_CHECK
(
m_bunchGroupFolderInputKey
.initialize(
SG::AllowEmpty
) );
27
ATH_CHECK
(
m_bunchGroupOutputKey
.initialize() );
28
return
StatusCode::SUCCESS;
29
}
30
31
36
StatusCode
37
BunchGroupCondAlg::execute
(
const
EventContext& ctx)
const
38
{
39
auto
bg = std::make_unique<BunchGroupCondData>();
40
const
EventIDBase::number_type UNDEFNUM = EventIDBase::UNDEFNUM;
41
const
EventIDBase::event_number_t UNDEFEVT = EventIDBase::UNDEFEVT;
42
EventIDRange range (EventIDBase (0, UNDEFEVT, UNDEFNUM, 0, 0),
43
EventIDBase (UNDEFNUM-1, UNDEFEVT, UNDEFNUM, 0, 0));
44
45
if
(!
m_bunchGroupFolderInputKey
.empty()) {
46
SG::ReadCondHandle<AthenaAttributeList>
bunchGroupFolder
47
(
m_bunchGroupFolderInputKey
, ctx);
48
ATH_CHECK
( bunchGroupFolder.
range
(range) );
49
50
if
((**bunchGroupFolder)[
"BunchCode"
].isNull()) {
51
ATH_MSG_ERROR
(
"BunchCode is NULL in "
<<
m_bunchGroupFolderInputKey
.key() <<
"!"
);
52
return
StatusCode::FAILURE;
53
}
54
55
// Do everything here for now, but should copy this to a vanilla object based on attrList
56
const
coral::Blob& blob = (**bunchGroupFolder)[
"BunchCode"
].data<coral::Blob>();
57
58
ATH_MSG_DEBUG
(
"Bunchgroup blob length: "
<< blob.size() );
59
60
// Verify length
61
// There have been many bugs, so just require at least NBCID
62
const
unsigned
int
NBCID =
BunchGroupCondData::NBCID
;
63
if
(
static_cast<
cool::UInt32
>
( blob.size() ) < NBCID) {
64
ATH_MSG_ERROR
(
"BunchCode length "
<< blob.size()
65
<<
" < "
<< NBCID <<
"!"
);
66
return
StatusCode::FAILURE;
67
}
68
69
// Decode all 8 bunch groups at once; read 8-bits at a time and decode.
70
const
uint8_t* p =
static_cast<
const
uint8_t*
>
(blob.startingAddress());
71
for
(
unsigned
int
bcid = 0; bcid < NBCID; ++bcid) {
72
bg->addBCID (bcid, p[bcid]);
73
}
74
75
// Print out physics bunch group
76
if
(
msgLvl
(MSG::DEBUG)) {
77
msg
(MSG::DEBUG) <<
"BunchGroup1 list: "
;
78
for
(
unsigned
int
bcid : bg->bunchGroup(1)) {
79
msg
(MSG::DEBUG) << bcid <<
" "
;
80
}
81
msg
(MSG::DEBUG) <<
endmsg
;
82
}
83
84
ATH_MSG_DEBUG
(
"Bunch Group 0 entries: "
<< bg->bunchGroup(0).size() );
85
ATH_MSG_DEBUG
(
"Bunch Group 1 entries: "
<< bg->bunchGroup(1).size() );
86
ATH_MSG_DEBUG
(
"Bunch Group 2 entries: "
<< bg->bunchGroup(2).size() );
87
ATH_MSG_DEBUG
(
"Bunch Group 3 entries: "
<< bg->bunchGroup(3).size() );
88
ATH_MSG_DEBUG
(
"Bunch Group 4 entries: "
<< bg->bunchGroup(4).size() );
89
ATH_MSG_DEBUG
(
"Bunch Group 5 entries: "
<< bg->bunchGroup(5).size() );
90
ATH_MSG_DEBUG
(
"Bunch Group 6 entries: "
<< bg->bunchGroup(6).size() );
91
ATH_MSG_DEBUG
(
"Bunch Group 7 entries: "
<< bg->bunchGroup(7).size() );
92
}
93
94
bg->shrink();
95
SG::WriteCondHandle<BunchGroupCondData>
bunchGroupData
96
(
m_bunchGroupOutputKey
, ctx);
97
ATH_CHECK
( bunchGroupData.
record
(range, std::move (bg)) );
98
return
StatusCode::SUCCESS;
99
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
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
BunchGroupCondAlg.h
Conditions algorithm to unpack bunch group data from COOL.
ReadCondHandle.h
WriteCondHandle.h
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
BunchGroupCondAlg::m_bunchGroupOutputKey
SG::WriteCondHandleKey< BunchGroupCondData > m_bunchGroupOutputKey
Output conditions object.
Definition
Database/CoolLumiUtilities/src/BunchGroupCondAlg.h:50
BunchGroupCondAlg::m_bunchGroupFolderInputKey
SG::ReadCondHandleKey< AthenaAttributeList > m_bunchGroupFolderInputKey
Input conditions object.
Definition
Database/CoolLumiUtilities/src/BunchGroupCondAlg.h:46
BunchGroupCondAlg::initialize
virtual StatusCode initialize() override
Gaudi initialize method.
Definition
Database/CoolLumiUtilities/src/BunchGroupCondAlg.cxx:24
BunchGroupCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm execute method.
Definition
Database/CoolLumiUtilities/src/BunchGroupCondAlg.cxx:37
BunchGroupCondData::NBCID
static constexpr unsigned int NBCID
Maximum size of BCID vectors.
Definition
BunchGroupCondData.h:35
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition
ReadCondHandle.h:223
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
Generated on
for ATLAS Offline Software by
1.17.0