ATLAS Offline Software
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  */
12 #include "BunchGroupCondAlg.h"
15 #include "CoralBase/Blob.h"
16 #include "CoolKernel/IObject.h"
17 #include <stdint.h>
18 
19 
25 {
28  return StatusCode::SUCCESS;
29 }
30 
31 
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 
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();
96  (m_bunchGroupOutputKey, ctx);
97  ATH_CHECK( bunchGroupData.record (range, std::move (bg)) );
98  return StatusCode::SUCCESS;
99 }
BunchGroupCondAlg::m_bunchGroupFolderInputKey
SG::ReadCondHandleKey< AthenaAttributeList > m_bunchGroupFolderInputKey
Input conditions object.
Definition: Database/CoolLumiUtilities/src/BunchGroupCondAlg.h:46
StandaloneBunchgroupHandler.bg
bg
Definition: StandaloneBunchgroupHandler.py:243
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
BunchGroupCondData::NBCID
constexpr static unsigned int NBCID
Maximum size of BCID vectors.
Definition: BunchGroupCondData.h:35
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
AtlasMcWeight::number_type
unsigned int number_type
Definition: AtlasMcWeight.h:20
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition: ReadCondHandle.h:224
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
ReadCondHandle.h
event_number_t
EventIDBase::event_number_t event_number_t
Definition: IEvtIdModifierSvc.h:30
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
BunchGroupCondAlg::initialize
virtual StatusCode initialize() override
Gaudi initialize method.
Definition: Database/CoolLumiUtilities/src/BunchGroupCondAlg.cxx:24
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
WriteCondHandle.h
BunchGroupCondAlg.h
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
BunchGroupCondAlg::m_bunchGroupOutputKey
SG::WriteCondHandleKey< BunchGroupCondData > m_bunchGroupOutputKey
Output conditions object.
Definition: Database/CoolLumiUtilities/src/BunchGroupCondAlg.h:50
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
BunchGroupCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm execute method.
Definition: Database/CoolLumiUtilities/src/BunchGroupCondAlg.cxx:37
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96