ATLAS Offline Software
Loading...
Searching...
No Matches
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"
15#include "CoralBase/Blob.h"
16#include "CoolKernel/IObject.h"
17#include <stdint.h>
18
19
23StatusCode
25{
27 ATH_CHECK( m_bunchGroupOutputKey.initialize() );
28 return StatusCode::SUCCESS;
29}
30
31
36StatusCode
37BunchGroupCondAlg::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()) {
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();
97 ATH_CHECK( bunchGroupData.record (range, std::move (bg)) );
98 return StatusCode::SUCCESS;
99}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Conditions algorithm to unpack bunch group data from COOL.
bool msgLvl(const MSG::Level lvl) const
SG::WriteCondHandleKey< BunchGroupCondData > m_bunchGroupOutputKey
Output conditions object.
SG::ReadCondHandleKey< AthenaAttributeList > m_bunchGroupFolderInputKey
Input conditions object.
virtual StatusCode initialize() override
Gaudi initialize method.
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm execute method.
static constexpr unsigned int NBCID
Maximum size of BCID vectors.
bool range(EventIDRange &r)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED