All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HiveTestAlgorithm.cpp
Go to the documentation of this file.
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 
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 
43 {
44 }
45 
48 {
49  info() << ":HiveTestAlgorithm::initialize " << endmsg;
50 
51  return StatusCode::SUCCESS;
52 }
53 
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 
78 {
79  info() << name( ) << ":HiveTestAlgorithm::finalize - total events: " << m_total << endmsg;
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 
static atomic< int > c_instances
#define DECLARE_ALGORITHM_FACTORY(x)
Definition: Algorithm.h:946
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MyObject(const MyObject &o)
virtual const std::vector< std::string > get_outputs()
STL namespace.
static void dump()
static atomic< int > d_instances
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
The useful base class for data processing algorithms.
virtual ~HiveTestAlgorithm()
Destructor.
#define class
HiveTestAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor(s)
virtual const std::vector< std::string > get_inputs()
std::vector< std::string > m_outputs
std::vector< std::string > m_inputs
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
list i
Definition: ana.py:128