The Gaudi Framework  v38r3 (c3fc9673)
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>
14 #include <string>
15 #include <vector>
16 
17 namespace Gaudi::TestSuite::NTuple {
18  struct IntVectorDataProducer final
19  : Gaudi::Functional::Producer<std::vector<int>(), Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
21  : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyVector" ) ) {}
22 
23  std::vector<int> operator()() const override { return std::vector<int>{ 0, 1, 2, 3, 4 }; }
24  };
25 
26  DECLARE_COMPONENT( IntVectorDataProducer )
27 
28  struct FloatDataProducer final
29  : Gaudi::Functional::Producer<float(), Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
31  : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyFloat" ) ) {}
32 
33  float operator()() const override { return 2.5; }
34  };
35 
36  DECLARE_COMPONENT( FloatDataProducer )
37 
38  struct StrDataProducer final
39  : Gaudi::Functional::Producer<std::string(), Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
41  : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyString" ) ) {}
42 
43  std::string operator()() const override { return m_stringValue; }
44 
45  private:
46  Gaudi::Property<std::string> m_stringValue{ this, "StringValue", "Default string", "Specify the string to write" };
47  };
48 
49  DECLARE_COMPONENT( StrDataProducer )
50 
51  struct StructDataProducer final
52  : Gaudi::Functional::Producer<Gaudi::TestSuite::NTuple::MyStruct(),
53  Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
55  : Producer( name, svcLoc, KeyValue( "OutputLocation", "MyStruct" ) ) {}
56 
58  Gaudi::TestSuite::NTuple::MyStruct myStruct = { 1, "myStruct" };
59  return myStruct;
60  }
61  };
62 
63  DECLARE_COMPONENT( StructDataProducer )
64 
65 } // namespace Gaudi::TestSuite::NTuple
Gaudi::TestSuite::NTuple::StructDataProducer
Definition: NTupleWriterProducers.cpp:53
std::string
STL class.
Gaudi::TestSuite::NTuple::StrDataProducer::operator()
std::string operator()() const override
Definition: NTupleWriterProducers.cpp:43
TestSuite
#define TestSuite
Definition: MakeAndConsume.cpp:634
std::vector< int >
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::TestSuite::NTuple::FloatDataProducer
Definition: NTupleWriterProducers.cpp:29
Gaudi::TestSuite::NTuple::MyStruct
Definition: MyStruct.h:16
Gaudi::Functional::Producer
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Definition: Producer.h:36
Gaudi::TestSuite::NTuple
Definition: MyStruct.h:15
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
Gaudi::TestSuite::NTuple::StrDataProducer
Definition: NTupleWriterProducers.cpp:39
Algorithm.h
Gaudi::Functional::details::Producer
Definition: Producer.h:21
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Gaudi::TestSuite::NTuple::StrDataProducer::StrDataProducer
StrDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:40
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Gaudi::TestSuite::NTuple::StructDataProducer::StructDataProducer
StructDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:54
Gaudi::TestSuite::NTuple::IntVectorDataProducer
Definition: NTupleWriterProducers.cpp:19
Gaudi::TestSuite::NTuple::FloatDataProducer::operator()
float operator()() const override
Definition: NTupleWriterProducers.cpp:33
std
STL namespace.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
Gaudi::Functional::Traits::BaseClass_t
Definition: utilities.h:40
NTuple
NTuple name space.
Definition: INTupleSvc.h:19
Gaudi::TestSuite::NTuple::IntVectorDataProducer::operator()
std::vector< int > operator()() const override
Definition: NTupleWriterProducers.cpp:23
Gaudi::TestSuite::NTuple::StructDataProducer::operator()
Gaudi::TestSuite::NTuple::MyStruct operator()() const override
Definition: NTupleWriterProducers.cpp:57
Gaudi::TestSuite::NTuple::IntVectorDataProducer::IntVectorDataProducer
IntVectorDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:20
Producer.h
Gaudi::TestSuite::NTuple::FloatDataProducer::FloatDataProducer
FloatDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:30
MyStruct.h
Gaudi::Property< std::string >