1 #include "art/Framework/Core/EDProducer.h"
2 #include "art/Framework/Core/ModuleMacros.h"
3 #include "art/Framework/Principal/Event.h"
4 #include "art/Framework/Principal/Handle.h"
5 #include "art/Framework/Services/Registry/ServiceHandle.h"
6 #include "canvas/Utilities/InputTag.h"
8 #include "art/Persistency/Common/PtrMaker.h"
9 #include "canvas/Persistency/Common/FindManyP.h"
10 #include "fhiclcpp/types/Atom.h"
11 #include "fhiclcpp/types/Table.h"
48 Name(
"inputPFParticleLabel"),
49 Comment(
"Label of recob::PFParticle Collection to be fit")};
51 Name(
"inputTracksLabel"),
52 Comment(
"Label of recob::Track Collection associated to PFParticles")};
57 fhicl::Table<VertexFitter::Inputs>
inputs{
74 void produce(art::Event&
e)
override;
84 , pfParticleInputTag(
p().inputs().inputPFParticleLabel())
85 , trackInputTag(
p().inputs().inputTracksLabel())
86 , fitter(
p().geom3dvtxfit,
p().propagator)
88 produces<std::vector<recob::Vertex>>();
89 produces<art::Assns<recob::PFParticle, recob::Vertex>>();
90 produces<art::Assns<recob::Vertex, recob::Track, recob::VertexAssnMeta>>();
98 auto outputVertices = make_unique<vector<recob::Vertex>>();
99 auto outputPFVxAssn = make_unique<art::Assns<recob::PFParticle, recob::Vertex>>();
100 auto outputVxTkMtAssn =
101 make_unique<art::Assns<recob::Vertex, recob::Track, recob::VertexAssnMeta>>();
103 const auto& inputPFParticle = e.getValidHandle<vector<recob::PFParticle>>(pfParticleInputTag);
104 art::FindManyP<recob::Track>
const assocTracks{inputPFParticle,
e, trackInputTag};
106 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
109 art::PtrMaker<recob::Vertex> vtxPtrMaker(e);
111 for (
size_t iPF = 0; iPF < inputPFParticle->size(); ++iPF) {
113 art::Ptr<recob::PFParticle> pfp(inputPFParticle, iPF);
114 if (pfp->IsPrimary() ==
false || pfp->NumDaughters() < 2)
continue;
115 vector<art::Ptr<recob::Track>>
tracks;
116 auto& pfd = pfp->Daughters();
117 for (
auto ipfd : pfd) {
120 for (
size_t jPF = 0; jPF < inputPFParticle->size(); ++jPF) {
121 art::Ptr<recob::PFParticle> pfpd(inputPFParticle, jPF);
122 if (pfpd->Self() != ipfd)
continue;
123 vector<art::Ptr<recob::Track>> pftracks = assocTracks.at(jPF);
124 for (
auto t : pftracks) {
130 if (tracks.size() < 2)
continue;
133 if (vtx.
isValid() ==
false)
continue;
136 auto meta = fitter.computeMeta(
detProp, vtx, tracks);
140 outputVertices->emplace_back(vtx.
vertex());
141 const art::Ptr<recob::Vertex> aptr = vtxPtrMaker(outputVertices->size() - 1);
142 outputPFVxAssn->addSingle(art::Ptr<recob::PFParticle>(inputPFParticle, iPF), aptr);
145 for (
auto t : tracks) {
146 outputVxTkMtAssn->addSingle(aptr, t, meta[itt]);
151 e.put(std::move(outputVertices));
152 e.put(std::move(outputPFVxAssn));
153 e.put(std::move(outputVxTkMtAssn));
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
VertexFitter & operator=(VertexFitter const &)=delete
fhicl::Table< Geometric3DVertexFitter::Config > geom3dvtxfit
ClusterModuleLabel join with tracks
VertexFitter(Parameters const &p)
Wrapper class to facilitate vertex production.
art::InputTag pfParticleInputTag
fhicl::Table< VertexFitter::Inputs > inputs
art::EDProducer::Table< Config > Parameters
3D vertex fitter based on the geometric properties (start position, direction, covariance) of the tra...
Module for fitting a vertex using the Geometric3DVertexFitter.
fhicl::Table< TrackStatePropagator::Config > propagator
art::InputTag trackInputTag
BEGIN_PROLOG vertical distance to the surface Name
void setVertexId(int newID)
Geometric3DVertexFitter fitter
void produce(art::Event &e) override
const recob::Vertex & vertex() const