36 using extends::extends;
44 : ToolBinder{
std::move( type ),
47 {
"MyInt",
"/Event/MyInt" },
48 construct<BoundInstance>(
this ) } {}
57 parent->always() <<
"BoundInstance - got: " <<
i <<
" from " <<
parent->inputLocation<
int>() <<
endmsg;
67 : Consumer( name, svcLoc, {
"MyTool",
"MyExampleTool" } ) {}
80 always() <<
"CountingConsumer: incrementing \"This is not an error\" twice" <<
endmsg;
84 always() <<
"CountingConsumer: incrementing \"This is not a warning\" twice" <<
endmsg;
88 always() <<
"CountingConsumer: incrementing \"This is not info\" twice" <<
endmsg;
99 : Producer( name, svcLoc, {
"OutputLocation",
"/Event/MyInt" } ) {}
102 info() <<
"executing IntDataProducer, storing " <<
m_value.value() <<
" into " << outputLocation() <<
endmsg;
114 : Producer( name, svcLoc, {
"OutputLocation",
"/Event/MyString" } ) {}
117 info() <<
"executing StringDataProducer, storing " <<
m_value.value() <<
" into " << outputLocation() <<
endmsg;
131 : Producer( name, svcLoc, {
"OutputLocation",
"/Event/MyVector" } ) {}
134 info() <<
"executing VectorDataProducer, storing " <<
m_data.value() <<
" into " << outputLocation() <<
endmsg;
145 : Producer( name, svcLoc, {
"OutputLocation",
"/Event/MyKeyed" } ) {}
153 info() <<
"executing KeyedDataProducer, storing [4,5] into " << outputLocation() <<
endmsg;
163 : Consumer( name, svcLoc, {
"InputLocation",
"/Event/MyInt" } ) {}
166 info() <<
"executing IntDataConsumer, consuming " << input <<
" from " << inputLocation() <<
endmsg;
175 : Consumer( name, svcLoc, {
"InputLocation",
"/Event/MyString" } ) {}
178 info() <<
"executing StringDataConsumer, consuming " << input <<
" from " << inputLocation() <<
endmsg;
187 : Transformer( name, svcLoc, {
"InputLocation",
"/Event/MyInt" }, {
"OutputLocation",
"/Event/MyFloat" } ) {}
190 info() <<
"Converting: " << input <<
" from " << inputLocation() <<
" and storing it into " << outputLocation()
201 : Transformer( name, svcLoc, { {
"InputLocation",
"/Event/MyInt" }, {
"OtherInput",
"/Event/MyOtherFloat" } },
202 {
"OutputLocation",
"/Event/OtherFloat" } ) {}
204 float operator()(
const int& in1,
const float& in2 )
const override {
205 info() <<
"Converting: " << in1 <<
" from " << inputLocation<int>() <<
" and " << in2 <<
" from "
206 << inputLocation<float>() <<
" and storing it into " << outputLocation() <<
endmsg;
217 name, svcLoc, { {
"InputLocation1",
"/Event/MyInt" }, {
"InputLocation2",
"/Event/MyOtherInt" } },
218 { {
"OutputLocation1",
"/Event/MyMultiFloat1" }, {
"OutputLocation2",
"/Event/MyMultiFloat2" } } ) {}
220 std::tuple<float, float>
operator()(
const int& input1,
const int& input2 )
const override {
221 info() <<
"Number of inputs : " << inputLocationSize() <<
", number of outputs : " << outputLocationSize()
223 info() <<
"Converting " << input1 <<
" from " << inputLocation<0>() <<
" and " << input2 <<
" from "
224 << inputLocation<1>() <<
endmsg;
225 info() <<
"Storing results into " << outputLocation<0>() <<
" and " << outputLocation<1>() <<
endmsg;
226 return std::tuple<float, float>{ input1, input2 };
239 : MergingTransformer( name, svcLoc, {
"InputLocations", {} },
240 {
"OutputLocation",
"/Event/MyConcatenatedIntVector" } ) {}
245 auto nelements = std::accumulate( intVectors.begin(), intVectors.end(), 0,
246 [](
const auto a,
const auto b ) { return a + b.size(); } );
247 std::vector<int> out;
248 out.reserve( nelements );
250 for (
auto& intVector : intVectors ) {
251 info() <<
"Concatening vector " << intVector <<
endmsg;
252 out.insert( out.end(), intVector.begin(), intVector.end() );
255 info() <<
"Storing output vector " << out <<
" to " << outputLocation() <<
endmsg;
267 : MergingTransformer( name, svcLoc, {
"InputLocations", {} },
268 {
"OutputLocation",
"/Event/MyConcatenatedIntVector" } ) {}
273 auto nelements = std::accumulate( intVectors.begin(), intVectors.end(), 0,
274 [](
const auto a,
const auto b ) { return a + ( b ? b->size() : 0 ); } );
275 std::vector<int> out;
276 out.reserve( nelements );
278 for (
auto& intVector : intVectors ) {
279 info() <<
"Concatening vector " << intVector <<
endmsg;
281 out.insert( out.end(), intVector->begin(), intVector->end() );
285 info() <<
"Storing output vector " << out <<
" to " << outputLocation() <<
endmsg;
295 : Consumer( name, svcLoc, {
"InputLocation",
"/Event/MyFloat" } ) {}
298 info() <<
"executing FloatDataConsumer: " << input <<
endmsg;
309 info() <<
"executing ContextConsumer, got " << ctx <<
endmsg;
318 : Transformer( name, svcLoc, {
"OutputLoc",
"/Event/SomeOtherInt" } ) {}
321 info() <<
"executing ContextConsumer, got " << ctx <<
endmsg;
331 : Consumer( name, svcLoc, {
"InputLocation",
"/Event/MyInt" } ) {}
334 info() <<
"executing ContextIntConsumer, got context = " << ctx <<
", int = " << i <<
" from " << inputLocation()
344 : Producer( name, svcLoc, {
"OutputLocation",
"/Event/MyVectorOfDoubles" } ) {}
347 info() <<
"storing vector<double> into " << outputLocation() <<
endmsg;
348 return { 12.34, 56.78, 90.12, 34.56, 78.90 };
359 : MultiScalarTransformer( name, svcLoc, {
"InputDoubles",
"/Event/MyVectorOfDoubles" },
360 { {
"OutputFractions",
"/Event/MyVectorOfFractions" },
361 {
"OutputIntegers",
"/Event/MyVectorOfIntegers" } } ) {}
363 using MultiScalarTransformer::operator();
365 std::tuple<double, int>
operator()(
const double& d )
const {
367 double frac = std::frexp( d, &i );
368 info() <<
"Converting " << d <<
" -> " << frac <<
", " << i <<
endmsg;
379 : MultiScalarTransformer( name, svcLoc, {
"InputDoubles",
"/Event/MyVectorOfDoubles" },
380 { {
"OutputFractions",
"/Event/OptMyVectorOfFractions" },
381 {
"OutputIntegers",
"/Event/OptMyVectorOfIntegers" } } ) {}
383 using MultiScalarTransformer::operator();
385 std::optional<std::tuple<double, int>>
operator()(
const double& d )
const {
387 info() <<
"Skipping " << d <<
endmsg;
391 double frac = std::frexp( d, &i );
392 info() <<
"Converting " << d <<
" -> " << frac <<
", " << i <<
endmsg;
393 return std::make_tuple( frac, i );
404 { {
"InputFractions",
"/Event/MyVectorOfFractions" }, {
"InputIntegers",
"/Event/MyVectorOfIntegers" } },
405 {
"OutputDoubles",
"/Event/MyNewVectorOfDoubles" } ) {}
407 using ScalarTransformer::operator();
410 double d = std::ldexp( frac, i );
411 info() <<
"Converting " << i <<
", " << frac <<
" -> " << d <<
endmsg;
424 { {
"InputFractions",
"/Event/MyVectorOfFractions" }, {
"InputIntegers",
"/Event/MyVectorOfIntegers" } },
425 {
"OutputDoubles",
"/Event/MyOptVectorOfDoubles" } ) {}
427 using ScalarTransformer::operator();
429 std::optional<double>
operator()(
const double& frac,
const int& i )
const {
430 double d = std::ldexp( frac, i );
432 info() <<
"Skipping " << d <<
endmsg;
435 info() <<
"Converting " << i <<
", " << frac <<
" -> " << d <<
endmsg;
443 using Consumer::Consumer;
461 : Producer( name, svcLoc, {
"OutputLocation",
"/Event/MyS" } ) {}
465 for (
int i = 0; i <
j; ++i ) out.insert(
new S{} );
466 info() <<
"storing KeyedContainer of size " << out.size() <<
" into " << outputLocation() <<
endmsg;
480 : MergingTransformer( name, svcLoc, {
"InputRanges", {} },
481 {
"OutputLocation",
"/Event/MyConcatenatedIntFromSVector" } ) {}
485 std::vector<int> out;
487 for (
const auto& SVector : SVectors ) {
488 info() <<
"Concatening range of size " << SVector.size() <<
endmsg;
489 for (
auto* s : SVector ) { out.push_back( s->a ); }
491 info() <<
"Storing output vector " << out <<
" to " << outputLocation() <<
endmsg;
503 : MergingTransformer( name, svcLoc, {
"InputRanges", {} } ) {}
507 OptSVectors )
const override {
509 for (
const auto& OptSVector : OptSVectors ) {
510 if ( OptSVector.has_value() ) {
511 auto SVector = OptSVector.value();
512 info() <<
"Consuming vector of size: " << SVector.size() <<
endmsg;
514 info() <<
"Skipping empty optional range" <<
endmsg;
526 : MergingTransformer( name, svcLoc, {
"InputLocations", {} } ) {}
530 auto nelements = std::accumulate( intVectors.begin(), intVectors.end(), 0,
531 [](
const auto a,
const auto b ) { return a + b.size(); } );
532 info() <<
"sum of input sizes: " << nelements <<
endmsg;
534 for (
const auto& intVector : intVectors ) { info() <<
"Consuming vector " << intVector <<
endmsg; }
548 :
Base( name, svcLoc, {
"InputLocations", {} } ) {}
552 auto nelements = std::accumulate( intVectors.begin(), intVectors.end(), 0,
553 [](
const auto a,
const auto b ) { return a + b.size(); } );
554 info() <<
"sum of input sizes: " << nelements <<
endmsg;
556 for (
const auto& intVector : intVectors ) { info() <<
"Consuming vector " << intVector <<
endmsg; }
570 : Producer( name, pSvcLocator, {
"TrackLocation",
"" } ){};
585 : MergingMultiTransformer{
588 { {
"InputInts", {} }, {
"InputDoubles", {} } },
589 { {
"OutputInts",
"/Event/MySummedInts" }, {
"OutputDoubles",
"/Event/MySummedDoubles" } } } {}
591 std::tuple<std::vector<int>, std::vector<double>>
594 auto r = std::tuple{ std::vector<int>{}, std::vector<double>{} };
596 std::transform( begin( intVectors ), end( intVectors ), std::back_inserter( is ),
597 [](
const std::vector<int>& vi ) {
return std::accumulate( begin( vi ), end( vi ), 0 ); } );
598 always() <<
" accumulated: " << is <<
endmsg;
599 std::transform( begin( doubleVectors ), end( doubleVectors ), std::back_inserter( ds ),
600 [](
const std::vector<double>& vd ) {
return std::accumulate( begin( vd ), end( vd ), 0. ); } );
601 always() <<
" accumulated: " << ds <<
endmsg;
622 : Producer( name, svcLoc, {
"OutputLocation",
"/Event/MySharedFoo" } ) {}
625 auto foo = std::make_shared<Foo>(
m_value.value() );
626 info() <<
"executing ShrdPtrProducer, storing shared_ptr<Foo> with payload at " << foo.get() <<
" and value "
627 << foo->i <<
" into " << outputLocation() <<
endmsg;
639 : Consumer( name, svcLoc, {
"InputLocation",
"/Event/MySharedFoo" } ) {}
641 void operator()(
const std::shared_ptr<Foo>& foo )
const override {
642 info() <<
"executing ShrdPtrConsumer, got shared_ptr<Foo> with payload at " << foo.get() <<
" with value "
643 << foo->i <<
" from " << inputLocation() <<
endmsg;
659 : SplittingMergingTransformer( name, svcLoc, {
"InputLocations", {} }, {
"OutputLocations", {} } ) {}
664 for (
const auto& iv : intVectors ) { info() <<
"loaded " << iv <<
" from " << inputLocation( l++ ) <<
endmsg; }
665 std::vector<int> out( outputLocationSize(), 0 );
666 for (
const auto& [l, r] :
m_mapping.value() ) {
667 out[l] = std::accumulate( intVectors.at( r ).begin(), intVectors.at( r ).end(), out[l] );
670 for (
const auto& o : out ) { info() <<
"storing " << o <<
" in " << outputLocation( l++ ) <<
endmsg; }
685 : SplittingMergingTransformer( name, svcLoc, { {
"InputLocations", {} }, {
"Scale",
"/Event/MyInt" } },
686 {
"OutputLocations", {} } ) {}
690 const int& scale )
const override {
691 info() <<
"executing with context " << ctx <<
", scale " << scale <<
" from " << inputLocation<1>() <<
endmsg;
692 std::vector<int> out( outputLocationSize(), 0 );
693 for (
const auto& [l, r] :
m_mapping.value() ) {
694 out[l] = std::accumulate( intVectors.at( r ).begin(), intVectors.at( r ).end(), out[l] );
696 for (
auto& value : out ) { value *= scale; }
711 parent = std::exchange( other.parent,
nullptr );
712 action = std::exchange( other.action,
nullptr );
723 Gaudi::Functional::Traits::use_<BaseClass_t, Gaudi::Functional::Traits::WriteOpaqueFor<Eventually>>> {
726 : Producer( name, svcLoc, {
"OutputLocation",
"/Event/Eventually" } ) {}
729 always() <<
"creating Eventually" <<
endmsg;
731 me->always() <<
"My Eventually is about to be destroyed" <<
endmsg;
738 static_assert( std::ranges::forward_range<Gaudi::Functional::vector_of_const_<void*>> );
739 static_assert( std::ranges::forward_range<Gaudi::Functional::vector_of_const_<int>> );
740 static_assert( std::ranges::forward_range<Gaudi::Functional::vector_of_const_<std::vector<int>*>> );
741 static_assert( std::ranges::forward_range<Gaudi::Functional::vector_of_const_<std::vector<int>>> );
742 static_assert( std::same_as<typename Gaudi::Functional::vector_of_const_<std::vector<int>*>::value_type,
743 std::vector<int>
const*> );
744 static_assert( std::same_as<typename Gaudi::Functional::vector_of_const_<std::vector<int>>::value_type,
745 std::vector<int>
const> );
747 std::same_as<typename Gaudi::Functional::vector_of_const_<Gaudi::Range_<std::vector<void*>>>::value_type,
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
This class represents an entry point to all the event specific data.
Base class from which all concrete algorithm classes should be derived.
Implementation of property with value of concrete type.
Useful class for representation of "sequence" of the objects through the range of valid iterators.
Definition of the basic interface.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
template class KeyedContainer, KeyedContainer.h
long add(ContainedObject *pObject) override
ObjectContainerBase overload: Add an object to the container.
Definition of the templated KeyedObject class.
KeyedObject()=default
Standard Constructor. The object key is preset to the invalid value.
Very simple class to represent the container of objects which are not owned by this container.
Base class used to extend a class implementing other interfaces.
details::Consumer< Signature, Traits_, details::isLegacy< Traits_ > > Consumer
details::MergingTransformer< Signature, Traits_, details::isLegacy< Traits_ > > MergingConsumer
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Gaudi::Range_< MyData::ConstVector > MyDataRange
KeyedContainer< KeyedObject< int >, Containers::HashMap > int_container
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...
void operator()(const EventContext &ctx) const override
void operator()(const EventContext &ctx, const int &i) const override
ContextIntConsumer(const std::string &name, ISvcLocator *svcLoc)
int operator()(const EventContext &ctx) const override
ContextTransformer(const std::string &name, ISvcLocator *svcLoc)
Gaudi::Accumulators::MsgCounter< MSG::INFO > m_info
Gaudi::Accumulators::MsgCounter< MSG::ERROR > m_err
Gaudi::Accumulators::MsgCounter< MSG::WARNING > m_warn
void operator()() const override
Eventually & operator=(Eventually const &)=delete
void(* action)(Gaudi::Algorithm const *)
Eventually(Gaudi::Algorithm const *p, void(*a)(Gaudi::Algorithm const *))
Eventually(Eventually const &)=delete
Eventually & operator=(Eventually &&other)
Eventually(Eventually &&other)
Gaudi::Algorithm const * parent
void operator()(const float &input) const override
FloatDataConsumer(const std::string &name, ISvcLocator *svcLoc)
Foo & operator=(Foo &&)=delete
Foo & operator=(const Foo &)=delete
IntDataConsumer(const std::string &name, ISvcLocator *svcLoc)
void operator()(const int &input) const override
int operator()() const override
Gaudi::Property< int > m_value
IntDataProducer(const std::string &name, ISvcLocator *svcLoc)
float operator()(const int &in1, const float &in2) const override
IntFloatToFloatData(const std::string &name, ISvcLocator *svcLoc)
IntIntToFloatFloatData(const std::string &name, ISvcLocator *svcLoc)
std::tuple< float, float > operator()(const int &input1, const int &input2) const override
IntToFloatData(const std::string &name, ISvcLocator *svcLoc)
float operator()(const int &input) const override
IntVectorsMerger(const std::string &name, ISvcLocator *svcLoc)
void operator()(const Gaudi::Functional::vector_of_const_< std::vector< int > > &intVectors) const override
void operator()(Gaudi::Functional::vector_of_const_< std::vector< int > > const &intVectors) const override
Gaudi::Functional::MergingConsumer< void(Gaudi::Functional::vector_of_const_< std::vector< int > > const &), BaseClass_t > Base
IntVectorsMergingConsumer(const std::string &name, ISvcLocator *svcLoc)
IntVectorsToIntVector(const std::string &name, ISvcLocator *svcLoc)
std::vector< int > operator()(const Gaudi::Functional::vector_of_const_< std::vector< int > > &intVectors) const override
IntVectorsToInts(const std::string &name, ISvcLocator *svcLoc)
std::vector< int > operator()(const Gaudi::Functional::vector_of_const_< std::vector< int > > &intVectors) const override
Gaudi::Property< std::vector< std::pair< int, int > > > m_mapping
Gaudi::Property< std::vector< std::pair< int, int > > > m_mapping
std::vector< int > operator()(const EventContext &ctx, const Gaudi::Functional::vector_of_const_< std::vector< int > > &intVectors, const int &scale) const override
IntVectorsToIntsWithContextAndScale(const std::string &name, ISvcLocator *svcLoc)
KeyedDataProducer(const std::string &name, ISvcLocator *svcLoc)
int_container operator()() const override
std::vector< const MyData * > ConstVector
OpaqueProducer(const std::string &name, ISvcLocator *svcLoc)
Eventually operator()() const override
void operator()(const Gaudi::Functional::vector_of_const_< std::optional< Gaudi::NamedRange_< std::vector< S const * > > > > &OptSVectors) const override
OptionalSRangesMerger(const std::string &name, ISvcLocator *svcLoc)
std::vector< int > operator()(const Gaudi::Functional::vector_of_const_< std::vector< int > * > &intVectors) const override
PIntVectorsToIntVector(const std::string &name, ISvcLocator *svcLoc)
MyDataRange operator()() const override
RangeProducer(const std::string &name, ISvcLocator *pSvcLocator)
SDataProducer(const std::string &name, ISvcLocator *svcLoc)
S::Container operator()() const override
KeyedObject()=default
Standard Constructor. The object key is preset to the invalid value.
KeyedContainer< S, Containers::HashMap > Container
SharedObjectsContainer< S > Selection
std::vector< S const * > ConstVector
std::vector< int > operator()(const Gaudi::Functional::vector_of_const_< Gaudi::Range_< std::vector< S const * > > > &SVectors) const override
SRangesToIntVector(const std::string &name, ISvcLocator *svcLoc)
ShrdPtrConsumer(const std::string &name, ISvcLocator *svcLoc)
void operator()(const std::shared_ptr< Foo > &foo) const override
Gaudi::Property< int > m_value
ShrdPtrProducer(const std::string &name, ISvcLocator *svcLoc)
std::shared_ptr< Foo > operator()() const override
void operator()(const std::string &input) const override
StringDataConsumer(const std::string &name, ISvcLocator *svcLoc)
std::string operator()() const override
Gaudi::Property< std::string > m_value
StringDataProducer(const std::string &name, ISvcLocator *svcLoc)
TwoDMerger(const std::string &name, ISvcLocator *svcLoc)
std::tuple< std::vector< int >, std::vector< double > > operator()(const Gaudi::Functional::vector_of_const_< std::vector< int > > &intVectors, const Gaudi::Functional::vector_of_const_< std::vector< double > > &doubleVectors) const override
VectorDataProducer(const std::string &name, ISvcLocator *svcLoc)
std::vector< int > operator()() const override
Gaudi::Property< std::vector< int > > m_data
std::vector< double > operator()() const override
VectorDoubleProducer(const std::string &name, ISvcLocator *svcLoc)
void operator()() const override
Base class to be used to extend an interface.