| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

HiveTestAlgorithm.cpp
Go to the documentation of this file.
1 #include "GaudiHive/HiveTestAlgorithm.h"
2 #include "GaudiKernel/MsgStream.h"
3 #include "GaudiKernel/AlgFactory.h"
4
5 #include <atomic>
6
7 DECLARE_ALGORITHM_FACTORY(HiveTestAlgorithm)
8
9 using namespace std;
10
11 class MyObject : public DataObject {
12 int m_data;
13 static atomic<int> c_instances;
14 static atomic<int> d_instances;
15 public:
16 MyObject(int d) : m_data(d) {c_instances++;}
17 MyObject(const MyObject& o) : DataObject(), m_data(o.m_data) {c_instances++;}
18 ~MyObject() {d_instances++;}
19 int getData() { return m_data; }
20 static void dump() { cout << "MyObject (C/D): " << c_instances << "/" << d_instances <<endl;}
21 };
22
23 atomic<int> MyObject::c_instances;
24 atomic<int> MyObject::d_instances;
25
29 HiveTestAlgorithm::HiveTestAlgorithm(const std::string& name, ISvcLocator* pSvcLocator) :
30 GaudiAlgorithm(name, pSvcLocator),
31 m_total( 0 ),
32 m_inputs( 0 ),
33 m_outputs( 0 )
34 {
35 declareProperty("Input", m_inputs, "List of required inputs");
36 declareProperty("Output", m_outputs, "List of provided outputs");
37 }
38
42 HiveTestAlgorithm::~HiveTestAlgorithm( )
43 {
44 }
45
46 StatusCode
47 HiveTestAlgorithm::initialize()
48 {
49 info() << ":HiveTestAlgorithm::initialize " << endmsg;
50
51 return StatusCode::SUCCESS;
52 }
53
54 StatusCode
55 HiveTestAlgorithm::execute()
56 {
57 ++m_total;
58 int evt = getContext()->evt();
59
60 info() << ":HiveTestAlgorithm::getting inputs... " << evt << endmsg;
61
62 for(vector<string>::iterator i = m_inputs.begin(); i != m_inputs.end(); i++) {
63 MyObject* obj = get<MyObject>(*i);
64 info() << "Got data " << *i << " with value " << obj->getData() << endmsg;
65 }
66
67 info() << ":HiveTestAlgorithm::registering outputs... " << evt << endmsg;
68
69 for(vector<string>::iterator i = m_outputs.begin(); i != m_outputs.end(); i++) {
70 put(new MyObject(1000+evt), *i);
71 }
72
73 return StatusCode::SUCCESS;
74 }
75
76 StatusCode
77 HiveTestAlgorithm::finalize()
78 {
79 info() << name( ) << ":HiveTestAlgorithm::finalize - total events: " << m_total << endmsg;
80 MyObject::dump();
81 return StatusCode::SUCCESS;
82 }
83
84 const std::vector<std::string> HiveTestAlgorithm::get_inputs()
85 {
86 return m_inputs;
87 }
88
89 const std::vector<std::string> HiveTestAlgorithm::get_outputs()
90 {
91 return m_outputs;
92 }
93
94
MyObject::c_instances
static atomic< int > c_instances
Definition: HiveTestAlgorithm.cpp:13
MyObject::~MyObject
~MyObject()
Definition: HiveTestAlgorithm.cpp:18
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
std::atomic< int >
MyObject::MyObject
MyObject(const MyObject &o)
Definition: HiveTestAlgorithm.cpp:17
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
MsgStream.h
HiveTestAlgorithm.h
MyObject::getData
int getData()
Definition: HiveTestAlgorithm.cpp:19
std::endl
T endl(T...args)
HiveTestAlgorithm::get_outputs
virtual const std::vector< std::string > get_outputs()
Definition: HiveTestAlgorithm.cpp:89
std
STL namespace.
GaudiAlgorithm::declareProperty
Property * declareProperty(const std::string &name, DataObjectHandle< T > &hndl, const std::string &doc="none") const
Definition: GaudiAlgorithm.h:695
std::list::end
T end(T...args)
MyObject::dump
static void dump()
Definition: HiveTestAlgorithm.cpp:20
MyObject
Definition: HiveTestAlgorithm.cpp:11
MyObject::d_instances
static atomic< int > d_instances
Definition: HiveTestAlgorithm.cpp:14
std::string
STL class.
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
read_lhcb_event_file.evt
tuple evt
Definition: read_lhcb_event_file.py:14
DECLARE_ALGORITHM_FACTORY
#define DECLARE_ALGORITHM_FACTORY(x)
Definition: Algorithm.h:777
GaudiAlgorithm
The useful base class for data processing algorithms.
Definition: GaudiAlgorithm.h:93
MyObject::m_data
int m_data
Definition: HiveTestAlgorithm.cpp:12
HiveTestAlgorithm::initialize
StatusCode initialize()
Definition: HiveTestAlgorithm.cpp:47
HiveTestAlgorithm::~HiveTestAlgorithm
virtual ~HiveTestAlgorithm()
Destructor.
Definition: HiveTestAlgorithm.cpp:42
std::vector
STL class.
class
#define class
Definition: AIDA_visibility_hack.h:24
std::list::begin
T begin(T...args)
HiveTestAlgorithm::HiveTestAlgorithm
HiveTestAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: HiveTestAlgorithm.cpp:29
HiveTestAlgorithm::finalize
StatusCode finalize()
Definition: HiveTestAlgorithm.cpp:77
HiveTestAlgorithm::get_inputs
virtual const std::vector< std::string > get_inputs()
Definition: HiveTestAlgorithm.cpp:84
HiveTestAlgorithm::m_outputs
std::vector< std::string > m_outputs
Definition: HiveTestAlgorithm.h:49
HiveTestAlgorithm::m_inputs
std::vector< std::string > m_inputs
Definition: HiveTestAlgorithm.h:48
MyObject::MyObject
MyObject(int d)
Definition: HiveTestAlgorithm.cpp:16
AlgFactory.h
HiveTestAlgorithm::execute
StatusCode execute()
Definition: HiveTestAlgorithm.cpp:55
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
ana.i
list i
Definition: ana.py:128
std::cout
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244