The Gaudi Framework  master (37c0b60a)
merging_transformer.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2023 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 \***********************************************************************************/
12 #include <string>
13 
19 
21  is2ff_merger( std::string const& name, ISvcLocator* pSvcLocator )
22  : is2ff_merger_base( name, pSvcLocator, { "InputInts", { "firstInt", "secondInt" } },
23  { KeyValue{ "O1", "firstFloat" }, KeyValue{ "O2", "secondFloat" } } ) {}
24 
25  out_t operator()( ints const& is ) const override {
26  float f1 = 1, f2 = 1;
27 
28  for ( auto i : is ) {
29  info() << "i: " << i << " ";
30  f1 *= i;
31  f2 *= 1.f / i;
32  }
33  info() << endmsg;
34  return { f1, f2 };
35  }
36 };
37 
38 DECLARE_COMPONENT( is2ff_merger )
39 
40 struct is2ff_merger_filter : public is2ff_merger_filter_base {
42  : is2ff_merger_filter_base( name, pSvcLocator, { "InputInts", { "firstInt", "secondInt" } },
43  { KeyValue{ "O1", "firstFloat" }, KeyValue{ "O2", "secondFloat" } } ) {}
44 
45  filter_out_t operator()( ints const& is ) const override {
46  float f1 = 1, f2 = 1;
47 
48  for ( auto i : is ) {
49  info() << "i: " << i << " ";
50  f1 *= i;
51  f2 *= 1.f / i;
52  }
53  info() << endmsg;
54  auto filter_passed = f1 > 10;
55  info() << "Filter " << ( filter_passed ? "passed" : "failed" ) << endmsg;
56  return { filter_passed, f1, f2 };
57  }
58 };
59 
60 DECLARE_COMPONENT( is2ff_merger_filter )
std::string
STL class.
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::Functional::MergingMultiTransformer
Definition: MergingTransformer.h:243
is2ff_merger_filter::is2ff_merger_filter
is2ff_merger_filter(std::string const &name, ISvcLocator *pSvcLocator)
Definition: merging_transformer.cpp:41
std::tuple
Gaudi::Functional::details::vector_of_const_
Definition: details.h:296
is2ff_merger_filter::operator()
filter_out_t operator()(ints const &is) const override
Definition: merging_transformer.cpp:45
is2ff_merger::operator()
out_t operator()(ints const &is) const override
Definition: merging_transformer.cpp:25
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Gaudi::Functional::MergingMultiTransformerFilter
Definition: MergingTransformer.h:341
out_t
std::tuple< float, float > out_t
Definition: merging_transformer.cpp:15
MergingTransformer.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
is2ff_merger::is2ff_merger
is2ff_merger(std::string const &name, ISvcLocator *pSvcLocator)
Definition: merging_transformer.cpp:21