ATLAS Offline Software
HiveAlgB.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "HiveAlgB.h"
6 #include <thread>
7 #include <chrono>
8 #include <memory>
9 
10 HiveAlgB::HiveAlgB( const std::string& name,
11  ISvcLocator* pSvcLocator ) :
12  HiveAlgBase( name, pSvcLocator ),
13  m_di(0) {}
14 
16 
17 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18 
20  ATH_MSG_DEBUG("initialize " << name());
21 
22  ATH_MSG_INFO("context: " << Gaudi::Hive::currentContext() << " for "
23  << this );
24 
25  ATH_MSG_INFO(" m_di was: " << m_di << " setting to -1 ");
26  m_di = -1;
27 
28  // dump out contents of context specific data
29  dump();
30 
32 
33  // initialize base class
34  return HiveAlgBase::initialize();
35 
36 }
37 
38 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
39 
41  ATH_MSG_INFO("context: " << Gaudi::Hive::currentContext());
42  ATH_MSG_DEBUG("finalize " << name());
43 
44  // dump out contents of context specific data
45  dump();
46 
47  return StatusCode::SUCCESS;
48 }
49 
50 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
51 
53 
54  ATH_MSG_DEBUG("execute " << name());
55 
56  ATH_MSG_INFO("context: " << Gaudi::Hive::currentContext() << " for "
57  << this);
58 
59  int s = sleep();
60 
61  ATH_MSG_INFO("m_di was: " << m_di << " setting to " << s);
62  m_di = s;
63 
65  ATH_CHECK(wrh1.record(std::make_unique< HiveDataObj >(20000)));
66 
67  ATH_MSG_INFO(" write: " << wrh1.key() << " = " << wrh1->val() );
68 
69  return StatusCode::SUCCESS;
70 
71 }
72 
73 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
74 
75 void
77 
78  std::ostringstream ost;
79 
80  // use a lambda to access all constituents of context specific data
81  m_di.for_all([&ost] (size_t s, const int i)
82  { ost << " s: " << s << " v: " << i << std::endl; } );
83 
84  ATH_MSG_INFO("dumping m_di: \n" << ost.str());
85 
86 }
87 
88 
HiveAlgB::finalize
virtual StatusCode finalize() override
Definition: HiveAlgB.cxx:40
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
HiveAlgB.h
Simple Algorithm that writes a single HiveDataObj to the store. It will also accumulate some data on ...
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HiveAlgBase::sleep
unsigned int sleep()
Definition: HiveAlgBase.cxx:42
HiveAlgB::execute
virtual StatusCode execute() override
Definition: HiveAlgB.cxx:52
HiveAlgBase::initialize
virtual StatusCode initialize() override
Definition: HiveAlgBase.cxx:25
HiveAlgB::~HiveAlgB
~HiveAlgB()
Definition: HiveAlgB.cxx:15
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
HiveAlgBase
Definition: HiveAlgBase.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
HiveAlgB::HiveAlgB
HiveAlgB(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HiveAlgB.cxx:10
HiveAlgB::initialize
virtual StatusCode initialize() override
Definition: HiveAlgB.cxx:19
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
HiveAlgB::m_wrh1
SG::WriteHandleKey< HiveDataObj > m_wrh1
Definition: HiveAlgB.h:42
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
HiveAlgB::dump
void dump()
Definition: HiveAlgB.cxx:76
HiveDataObj::val
void val(int i)
Definition: HiveDataObj.h:22
HiveAlgB::m_di
Gaudi::Hive::ContextSpecificData< int > m_di
Definition: HiveAlgB.h:47