The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
NTupleWriterProducers.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#include <Gaudi/Algorithm.h>
15#include <string>
16#include <vector>
17
20 : Gaudi::Functional::Producer<std::vector<int>(), Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
21 IntVectorDataProducer( const std::string& name, ISvcLocator* svcLoc )
22 : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyVector" ) ) {}
23
24 std::vector<int> operator()() const override { return std::vector<int>{ 0, 1, 2, 3, 4 }; }
25 };
26
27 DECLARE_COMPONENT( IntVectorDataProducer )
28
29 struct FloatDataProducer final
30 : Gaudi::Functional::Producer<float(), Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
31 FloatDataProducer( const std::string& name, ISvcLocator* svcLoc )
32 : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyFloat" ) ) {}
33
34 float operator()() const override { return 2.5; }
35 };
36
37 DECLARE_COMPONENT( FloatDataProducer )
38
39 struct StrDataProducer final
40 : Gaudi::Functional::Producer<std::string(), Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
41 StrDataProducer( const std::string& name, ISvcLocator* svcLoc )
42 : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyString" ) ) {}
43
44 std::string operator()() const override { return m_stringValue; }
45
46 private:
47 Gaudi::Property<std::string> m_stringValue{ this, "StringValue", "Default string", "Specify the string to write" };
48 };
49
50 DECLARE_COMPONENT( StrDataProducer )
51
52 struct StructDataProducer final
55 StructDataProducer( const std::string& name, ISvcLocator* svcLoc )
56 : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyStruct" ) ) {}
57
59 Gaudi::TestSuite::NTuple::MyStruct myStruct = { 1, "myStruct" };
60 return myStruct;
61 }
62 };
63
64 DECLARE_COMPONENT( StructDataProducer )
65
67 : Gaudi::Functional::Producer<Gaudi::TestSuite::Counter(),
69 CounterDataProducer( const std::string& name, ISvcLocator* svcLoc )
70 : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyCounter" ) ) {}
71
72 Counter operator()() const override { return Counter(); }
73 };
74 DECLARE_COMPONENT( CounterDataProducer )
75
76} // namespace Gaudi::TestSuite::NTuple
#define DECLARE_COMPONENT(type)
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:87
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Definition Producer.h:37
Gaudi::Functional::Traits::BaseClass_t< Gaudi::Algorithm > BaseClass_t
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
NTuple name space.
Definition INTupleSvc.h:16
STL namespace.
CounterDataProducer(const std::string &name, ISvcLocator *svcLoc)
FloatDataProducer(const std::string &name, ISvcLocator *svcLoc)
IntVectorDataProducer(const std::string &name, ISvcLocator *svcLoc)
StrDataProducer(const std::string &name, ISvcLocator *svcLoc)
StructDataProducer(const std::string &name, ISvcLocator *svcLoc)
Gaudi::TestSuite::NTuple::MyStruct operator()() const override