22
22
#include " k4FWCore/Producer.h"
23
23
24
24
#include " edm4hep/MCParticleCollection.h"
25
+ #include " edm4hep/RecoMCParticleLinkCollection.h"
25
26
#include " edm4hep/ReconstructedParticleCollection.h"
26
27
#include " edm4hep/SimTrackerHitCollection.h"
27
28
#include " edm4hep/TrackCollection.h"
35
36
using retType =
36
37
std::tuple<podio::UserDataCollection<float >, edm4hep::MCParticleCollection, edm4hep::MCParticleCollection,
37
38
edm4hep::SimTrackerHitCollection, edm4hep::TrackerHit3DCollection, edm4hep::TrackCollection,
38
- edm4hep::ReconstructedParticleCollection>;
39
+ edm4hep::ReconstructedParticleCollection, edm4hep::RecoMCParticleLinkCollection >;
39
40
40
41
struct ExampleFunctionalProducerMultiple final : k4FWCore::Producer<retType()> {
41
42
// The pairs in KeyValue can be changed from python and they correspond
@@ -48,7 +49,8 @@ struct ExampleFunctionalProducerMultiple final : k4FWCore::Producer<retType()> {
48
49
KeyValues (" OutputCollectionParticles2" , {" MCParticles2" }),
49
50
KeyValues (" OutputCollectionSimTrackerHits" , {" SimTrackerHits" }),
50
51
KeyValues (" OutputCollectionTrackerHits" , {" TrackerHits" }), KeyValues (" OutputCollectionTracks" , {" Tracks" }),
51
- KeyValues (" OutputCollectionRecoParticles" , {" RecoParticles" })}) {}
52
+ KeyValues (" OutputCollectionRecoParticles" , {" RecoParticles" }),
53
+ KeyValues (" OutputCollectionLinks" , {" Links" })}) {}
52
54
53
55
// This is the function that will be called to produce the data
54
56
retType operator ()() const override {
@@ -62,8 +64,8 @@ struct ExampleFunctionalProducerMultiple final : k4FWCore::Producer<retType()> {
62
64
63
65
auto particles = edm4hep::MCParticleCollection ();
64
66
edm4hep::Vector3d v{0 , 0 , 0 };
65
- particles.create (1 , 2 , 3 , 4 .f , 5 .f , 6 .f , v, v, v);
66
- particles.create (2 , 3 , 4 , 5 .f , 6 .f , 7 .f );
67
+ auto part1 = particles.create (1 , 2 , 3 , 4 .f , 5 .f , 6 .f , v, v, v);
68
+ auto part2 = particles.create (2 , 3 , 4 , 5 .f , 6 .f , 7 .f );
67
69
68
70
auto simTrackerHits = edm4hep::SimTrackerHitCollection ();
69
71
auto hit = simTrackerHits.create ();
@@ -88,13 +90,21 @@ struct ExampleFunctionalProducerMultiple final : k4FWCore::Producer<retType()> {
88
90
track.addToTracks (track2);
89
91
90
92
auto recos = edm4hep::ReconstructedParticleCollection ();
91
- for (int i = 1 ; i < 5 ; ++i) {
93
+ for (int i = 0 ; i < 5 ; ++i) {
92
94
auto reco = recos.create ();
93
95
reco.setPDG (i);
94
96
}
95
97
98
+ auto links = edm4hep::RecoMCParticleLinkCollection ();
99
+ for (size_t i = 0 ; i < 2 ; ++i) {
100
+ auto link = links.create ();
101
+ link .setFrom (recos[i]);
102
+ link .setTo (particles[i]);
103
+ }
104
+
96
105
return std::make_tuple (std::move (floatVector), std::move (particles), edm4hep::MCParticleCollection (),
97
- std::move (simTrackerHits), std::move (trackerHits), std::move (tracks), std::move (recos));
106
+ std::move (simTrackerHits), std::move (trackerHits), std::move (tracks), std::move (recos),
107
+ std::move (links));
98
108
}
99
109
100
110
private:
0 commit comments