-
Notifications
You must be signed in to change notification settings - Fork 26
/
ExampleFunctionalProducer.cpp
50 lines (42 loc) · 1.8 KB
/
ExampleFunctionalProducer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Copyright (c) 2014-2024 Key4hep-Project.
*
* This file is part of Key4hep.
* See https://key4hep.github.io/key4hep-doc/ for further info.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Gaudi/Property.h"
#include "edm4hep/MCParticleCollection.h"
#include "k4FWCore/Producer.h"
#include <string>
struct ExampleFunctionalProducer final : k4FWCore::Producer<edm4hep::MCParticleCollection()> {
// The pair in KeyValue can be changed from python and it corresponds
// to the name of the output collection
ExampleFunctionalProducer(const std::string& name, ISvcLocator* svcLoc)
: Producer(name, svcLoc, {}, KeyValues("OutputCollection", {"MCParticles"})) {}
// This is the function that will be called to produce the data
edm4hep::MCParticleCollection operator()() const override {
auto coll = edm4hep::MCParticleCollection();
coll.create(1, 2, 3, 4.f, 5.f, 6.f);
coll.create(2, 3, 4, 5.f, 6.f, 7.f);
// We have to return whatever collection type we specified in the
// template argument
return coll;
}
private:
// We can define any property we want that can be set from python
// and use it inside operator()
Gaudi::Property<int> m_exampleInt{this, "ExampleInt", 3, "Example int that can be used in the algorithm"};
};
DECLARE_COMPONENT(ExampleFunctionalProducer)