ATLAS Offline Software
SgStressProducer.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // SgStressProducer.cxx
8 // Implementation file for class SgStressProducer
9 // Author: S.Binet<binet@cern.ch>
11 
12 
13 // STL includes
14 #include <sstream>
15 
16 // FrameWork includes
17 #include "Gaudi/Property.h"
18 
19 // StoreGate
20 #include "StoreGate/StoreGateSvc.h"
21 
22 // DataModel includes
23 #include "AthAllocators/DataPool.h"
24 
25 // StoreGateTests includes
26 #include "StoreGateTests/PayLoad.h"
27 #include "SgStressProducer.h"
28 
30 
32 // Public methods:
34 
35 // Constructors
38  ISvcLocator* pSvcLocator ) :
39  AthAlgorithm( name, pSvcLocator )
40 {
41  //
42  // Property declaration
43  //
44  //declareProperty( "Property", m_nProperty );
45 
46  declareProperty( "DataName",
47  m_dataName = "MyData",
48  "Output location of 'Data' objects" );
49 
50  declareProperty( "NbrOfObjects",
51  m_nObjs = 1000,
52  "Number of 'Data' objects to be stored each event" );
53 
54  declareProperty( "ObjectsSize",
55  m_dataSize = 100,
56  "Size of each 'Data' objects to be stored each event" );
57 
58  declareProperty( "UseDataPool",
59  m_useDataPool = false,
60  "Switch to use or not an arena (memory pool) to allocate "
61  "payload" );
62 }
63 
64 // Destructor
67 {
68  ATH_MSG_DEBUG ( "Calling destructor" );
69 }
70 
71 // Athena Algorithm's Hooks
74 {
75  // configure our MsgStream
76  msg().setLevel( msgLevel() );
77 
78  ATH_MSG_INFO ( "Initializing " << name() << "..." );
79  return StatusCode::SUCCESS;
80 }
81 
83 {
84  ATH_MSG_INFO ( "Finalizing " << name() << "..." );
85  return StatusCode::SUCCESS;
86 }
87 
89 {
90  ATH_MSG_DEBUG ( "Executing " << name() << "..." );
91 
92  if ( !createData().isSuccess() ) {
93  ATH_MSG_ERROR ( "Could not create PayLoad data !!" );
94  return StatusCode::FAILURE;
95  }
96 
97  return StatusCode::SUCCESS;
98 }
99 
101 // Non-const methods:
103 
105 {
106  bool allGood = true;
108  if ( m_useDataPool ) {
110  pool.erase();
111  pool.reserve (m_nObjs);
112  }
113 
114  for ( std::size_t iObj = 0; iObj != m_nObjs; ++iObj ) {
115  std::ostringstream outName;
116  outName << m_dataName << "_payload_" << iObj;
117  SgTests::PayLoad * data = 0;
119 
120  if ( m_useDataPool ) {
121  dv->clear( SG::VIEW_ELEMENTS );
122  data = pool.nextElementPtr();
123  } else {
124  dv->clear( SG::OWN_ELEMENTS );
125  data = new SgTests::PayLoad;
126  }
127  dv->push_back( data );
128 
129  if ( !evtStore()->record(dv, outName.str()).isSuccess() ) {
130  ATH_MSG_ERROR ( "Could not store data at [" << outName.str() << "] !!" );
131  delete dv; dv = 0;
132  allGood = false;
133  continue;
134  }
135  if ( !evtStore()->setConst(dv).isSuccess() ) {
136  ATH_MSG_WARNING( "Could not setConst data at [" << outName.str() << "] !!");
137  }
138 
139  // filling data
140  data->m_data.reserve( m_dataSize );
141  for ( std::size_t i = 0; i != static_cast<std::size_t>(m_dataSize); ++i ) {
142  data->m_data.push_back( i );
143  }
144  }
145 
146  return allGood ? StatusCode::SUCCESS : StatusCode::FAILURE;
147 }
148 
SgStressProducer::finalize
virtual StatusCode finalize()
Definition: SgStressProducer.cxx:82
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
SgTests::PayLoadDv
Definition: PayLoad.h:34
PlotCalibFromCool.dv
dv
Definition: PlotCalibFromCool.py:762
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
pool
pool namespace
Definition: libname.h:15
SgStressProducer::createData
StatusCode createData()
Create data.
Definition: SgStressProducer.cxx:104
SgStressProducer::execute
virtual StatusCode execute()
Definition: SgStressProducer.cxx:88
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SgStressProducer.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
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
SgStressProducer::initialize
virtual StatusCode initialize()
Definition: SgStressProducer.cxx:73
SgStressProducer::SgStressProducer
SgStressProducer()
Default constructor:
checkRpcDigits.allGood
bool allGood
Loop over the SDOs & Digits.
Definition: checkRpcDigits.py:171
AthAlgorithm
Definition: AthAlgorithm.h:47
DataPool.h
TestSUSYToolsAlg.outName
string outName
Definition: TestSUSYToolsAlg.py:173
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
PayLoad.h
SgStressProducer::m_nObjs
std::size_t m_nObjs
Number of payload objects.
Definition: SgStressProducer.h:79
SgStressProducer::m_dataSize
std::size_t m_dataSize
Size of the payload objects.
Definition: SgStressProducer.h:82
PayLoadPool_t
DataPool< SgTests::PayLoad > PayLoadPool_t
Definition: SgStressProducer.cxx:29
SgStressProducer::~SgStressProducer
virtual ~SgStressProducer()
Destructor:
Definition: SgStressProducer.cxx:66
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SgStressProducer::m_dataName
std::string m_dataName
Name of the input data.
Definition: SgStressProducer.h:76
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:63
SgStressProducer::m_useDataPool
bool m_useDataPool
switch to use or not an arena (memory pool) to allocate payload
Definition: SgStressProducer.h:85
StoreGateSvc.h
SgTests::PayLoad
Definition: PayLoad.h:28