The Gaudi Framework  master (37c0b60a)
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 <GaudiTestSuite/Counter.h>
15 #include <string>
16 #include <vector>
17 
18 namespace Gaudi::TestSuite::NTuple {
19  struct IntVectorDataProducer final
20  : Gaudi::Functional::Producer<std::vector<int>(), Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
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>> {
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>> {
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
53  : Gaudi::Functional::Producer<Gaudi::TestSuite::NTuple::MyStruct(),
54  Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
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 
66  struct CounterDataProducer final
67  : Gaudi::Functional::Producer<Gaudi::TestSuite::Counter(),
68  Gaudi::Functional::Traits::BaseClass_t<Gaudi::Algorithm>> {
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
Gaudi::TestSuite::NTuple::StructDataProducer
Definition: NTupleWriterProducers.cpp:54
Gaudi::TestSuite::Counter
Definition: Counter.h:30
std::string
STL class.
Gaudi::TestSuite::NTuple::StrDataProducer::operator()
std::string operator()() const override
Definition: NTupleWriterProducers.cpp:44
TestSuite
#define TestSuite
Definition: MakeAndConsume.cpp:658
std::vector< int >
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::TestSuite::NTuple::FloatDataProducer
Definition: NTupleWriterProducers.cpp:30
Gaudi::TestSuite::NTuple::MyStruct
Definition: MyStruct.h:16
Gaudi::TestSuite::NTuple::CounterDataProducer::CounterDataProducer
CounterDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:69
Gaudi::Functional::Producer
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Definition: Producer.h:37
Gaudi::TestSuite::NTuple
Definition: MyStruct.h:15
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
Producer.h
Gaudi::TestSuite::NTuple::StrDataProducer
Definition: NTupleWriterProducers.cpp:40
Algorithm.h
Gaudi::Functional::details::Producer
Definition: Producer.h:22
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::TestSuite::NTuple::StrDataProducer::StrDataProducer
StrDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:41
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Gaudi::TestSuite::NTuple::StructDataProducer::StructDataProducer
StructDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:55
Gaudi::TestSuite::NTuple::IntVectorDataProducer
Definition: NTupleWriterProducers.cpp:20
Gaudi::TestSuite::NTuple::CounterDataProducer::operator()
Counter operator()() const override
Definition: NTupleWriterProducers.cpp:72
Gaudi::TestSuite::NTuple::FloatDataProducer::operator()
float operator()() const override
Definition: NTupleWriterProducers.cpp:34
std
STL namespace.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
Gaudi::TestSuite::NTuple::CounterDataProducer
Definition: NTupleWriterProducers.cpp:68
Gaudi::Functional::Traits::BaseClass_t
Definition: utilities.h:38
NTuple
NTuple name space.
Definition: INTupleSvc.h:19
Gaudi::TestSuite::NTuple::IntVectorDataProducer::operator()
std::vector< int > operator()() const override
Definition: NTupleWriterProducers.cpp:24
Gaudi::TestSuite::NTuple::StructDataProducer::operator()
Gaudi::TestSuite::NTuple::MyStruct operator()() const override
Definition: NTupleWriterProducers.cpp:58
Gaudi::TestSuite::NTuple::IntVectorDataProducer::IntVectorDataProducer
IntVectorDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:21
Gaudi::TestSuite::NTuple::FloatDataProducer::FloatDataProducer
FloatDataProducer(const std::string &name, ISvcLocator *svcLoc)
Definition: NTupleWriterProducers.cpp:31
MyStruct.h
Gaudi::Property< std::string >
Counter.h