ATLAS Offline Software
Loading...
Searching...
No Matches
FillParamsCondAlg.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 "FillParamsCondAlg.h"
15#include "CoralBase/Blob.h"
16#include "CoolKernel/IObject.h"
17#include <stdint.h>
18
19#ifdef __linux__
20#include <endian.h>
21static_assert (__BYTE_ORDER == __LITTLE_ENDIAN,
22 "FillParamsCondAlg assumes little-endian byte ordering.");
23#endif
24
25
29StatusCode
31{
33 ATH_CHECK( m_fillParamsOutputKey.initialize() );
34 return StatusCode::SUCCESS;
35}
36
37
42StatusCode
43FillParamsCondAlg::execute (const EventContext& ctx) const
44{
47 EventIDRange range;
48 ATH_CHECK( fillParamsFolder.range (range) );
49
50 if ((**fillParamsFolder)["BCIDmasks"].isNull()) {
51 ATH_MSG_ERROR( "BunchCode is NULL in " << m_fillParamsFolderInputKey.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 cool::UInt32 nb1 = (**fillParamsFolder)["Beam1Bunches"].data<cool::UInt32>();
57 cool::UInt32 nb2 = (**fillParamsFolder)["Beam2Bunches"].data<cool::UInt32>();
58 cool::UInt32 ncol = (**fillParamsFolder)["LuminousBunches"].data<cool::UInt32>();
59
60 ATH_MSG_DEBUG( "Beam1Bunches: " << nb1 );
61 ATH_MSG_DEBUG( "Beam2Bunches: " << nb2 );
62 ATH_MSG_DEBUG( "LuminousBunches: " << ncol );
63
64 const coral::Blob& blob = (**fillParamsFolder)["BCIDmasks"].data<coral::Blob>();
65
66 // Verify length
67 if ( static_cast<cool::UInt32>( blob.size() ) != 2 * (nb1 + nb2 + ncol)) {
68 ATH_MSG_WARNING( "BCIDmasks length " << blob.size() << " != 2 * " << (nb1+nb2+ncol) );
69 return StatusCode::SUCCESS;
70 }
71
72 const uint16_t* p=static_cast<const uint16_t*>(blob.startingAddress());
73
74 auto fp = std::make_unique<FillParamsCondData>();
75
76 // Decode beam1 list
77 fp->setBeam1Bunches (p, p+nb1);
78 p += nb1;
79
80 // Decode beam2 list
81 fp->setBeam2Bunches (p, p+nb2);
82 p += nb2;
83
84 // Decode luminous list
85 fp->setLuminousBunches (p, p+ncol);
86 p += ncol;
87
90 ATH_CHECK( fillParamsData.record (range, std::move (fp)) );
91 return StatusCode::SUCCESS;
92}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Conditions algorithm to unpack fill parameters from COOL.
virtual StatusCode initialize() override final
Gaudi initialize method.
SG::ReadCondHandleKey< AthenaAttributeList > m_fillParamsFolderInputKey
Input conditions object.
virtual StatusCode execute(const EventContext &ctx) const override final
Algorithm execute method.
SG::WriteCondHandleKey< FillParamsCondData > m_fillParamsOutputKey
Output conditions object.
bool range(EventIDRange &r)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED