-
Notifications
You must be signed in to change notification settings - Fork 1
/
SignatureProducer_module.txt
74 lines (59 loc) · 2.63 KB
/
SignatureProducer_module.txt
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "art/Framework/Core/EDProducer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "fhiclcpp/ParameterSet.h"
#include "lardataobj/RecoBase/Track.h"
#include "lardataobj/RecoBase/Hit.h"
#include "lardataobj/RecoBase/SpacePoint.h"
#include "lardataobj/RecoBase/Cluster.h"
#include "lardataobj/RecoBase/PFParticle.h"
#include "lardata/Utilities/AssociationUtil.h"
#include <vector>
#include <map>
#include <memory>
#include "ConvolutionNetworkAlgo_module.cc"
class SignatureProducer : public art::EDProducer {
public:
explicit SignatureProducer(fhicl::ParameterSet const& pset);
void produce(art::Event& evt) override;
private:
recob::Track buildTrack(const std::vector<art::Ptr<recob::Hit>>& hits);
recob::SpacePoint buildSpacePointFromHit(const art::Ptr<recob::Hit>& hit, size_t id);
recob::Cluster buildClusterFromHits(const std::vector<art::Ptr<recob::Hit>>& hits, size_t id);
recob::PFParticle buildPFParticle(int pdgCode, size_t id);
std::unique_ptr<ConvolutionNetworkAlgo> _cnn_algo;
};
SignatureProducer::SignatureProducer(fhicl::ParameterSet const& pset)
: EDProducer{pset}
{
_cnn_algo = std::make_unique<ConvolutionNetworkAlgo>(pset);
produces<std::vector<recob::Track>>();
produces<std::vector<recob::SpacePoint>>();
produces<std::vector<recob::Cluster>>();
produces<std::vector<recob::PFParticle>>();
produces<art::Assns<recob::SpacePoint, recob::Hit>>();
produces<art::Assns<recob::Cluster, recob::Hit>>();
produces<art::Assns<recob::PFParticle, recob::Cluster>>();
}
void SignatureProducer::produce(art::Event& evt)
{
auto clus_coll = std::make_unique<std::vector<recob::Cluster>>();
auto sp_coll = std::make_unique<std::vector<recob::SpacePoint>>();
auto pfp_coll = std::make_unique<std::vector<recob::PFParticle>>();
auto trck_coll = std::make_unique<std::vector<recob::Track>>();
auto sp_hit_assns = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
auto clus_hit_assns = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
auto pfp_clus_assns = std::make_unique<art::Assns<recob::PFParticle, recob::Cluster>>();
std::map<int, std::vector<art::Ptr<recob::Hit>>> class_hits;
_cnn_algo->infer(evt, class_hits);
// build new reconstruction objects
evt.put(std::move(clus_coll));
evt.put(std::move(sp_coll));
evt.put(std::move(pfp_coll));
evt.put(std::move(trck_coll));
evt.put(std::move(sp_hit_assns));
evt.put(std::move(clus_hit_assns));
evt.put(std::move(pfp_clus_assns));
}
DEFINE_ART_MODULE(SignatureProducer)