17 #include "art/Framework/Core/EDProducer.h"
18 #include "art/Framework/Core/ModuleMacros.h"
19 #include "art/Framework/Principal/Event.h"
20 #include "art/Framework/Principal/Handle.h"
21 #include "art/Framework/Principal/Run.h"
22 #include "art/Framework/Principal/SubRun.h"
23 #include "art/Utilities/make_tool.h"
24 #include "canvas/Utilities/InputTag.h"
25 #include "fhiclcpp/ParameterSet.h"
26 #include "messagefacility/MessageLogger/MessageLogger.h"
57 class VertexStubTracker;
74 void produce(art::Event&
e)
override;
92 fPFPLabel(
p.get<art::InputTag>(
"PFPLabel",
"pandora")),
93 fTrackLabel(
p.get<art::InputTag>(
"TrackLabel",
"pandoraTrack")),
94 fVertexChargeLabel(
p.get<art::InputTag>(
"VertexChargeLabel",
"vhit")),
95 fdQdxCut(
p.get<
float>(
"dQdxCut")),
96 fOneWiredQdxCut(
p.get<
float>(
"OneWiredQdxCut")),
97 fCorrectSCE(
p.get<
bool>(
"CorrectSCE")),
98 fPositionsAreSCECorrected(
p.get<
bool>(
"PositionsAreSCECorrected")),
99 fStubBuilder(
p.get<fhicl::ParameterSet >(
"CaloAlg"), fPositionsAreSCECorrected)
102 std::vector<fhicl::ParameterSet> merge_tool_configs(
p.get<std::vector<fhicl::ParameterSet>>(
"MergeTools"));
103 for (
unsigned i = 0; i < merge_tool_configs.size(); i++) {
104 fStubMergeTools.push_back(art::make_tool<IStubMerge>(merge_tool_configs[i]));
107 produces<std::vector<sbn::Stub>>();
108 produces<art::Assns<sbn::VertexHit, sbn::Stub>>();
109 produces<art::Assns<sbn::Stub, recob::Hit>>();
110 produces<art::Assns<sbn::Stub, recob::Slice>>();
111 produces<art::Assns<sbn::Stub, recob::PFParticle>>();
119 auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
121 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e, clock_data);
124 if (!fCorrectSCE) sce =
nullptr;
127 std::unique_ptr<std::vector<sbn::Stub>> outStubs(
new std::vector<sbn::Stub>);
128 std::unique_ptr<art::Assns<sbn::VertexHit, sbn::Stub>> assn(
new art::Assns<sbn::VertexHit, sbn::Stub>);
129 std::unique_ptr<art::Assns<sbn::Stub, recob::Hit>> hitAssn(
new art::Assns<sbn::Stub, recob::Hit>);
130 std::unique_ptr<art::Assns<sbn::Stub, recob::Slice>> slcAssn(
new art::Assns<sbn::Stub, recob::Slice>);
131 std::unique_ptr<art::Assns<sbn::Stub, recob::PFParticle>> pfpAssn(
new art::Assns<sbn::Stub, recob::PFParticle>);
133 art::PtrMaker<sbn::Stub> StubPtrMaker {e};
136 art::Handle<std::vector<recob::Slice>> slice_handle;
137 e.getByLabel(fPFPLabel, slice_handle);
139 std::vector<art::Ptr<recob::Slice>>
slices;
140 art::fill_ptr_vector(slices, slice_handle);
142 art::FindManyP<sbn::VertexHit> slcVHits(slices, e, fVertexChargeLabel);
145 fStubBuilder.Setup(e, fPFPLabel, fTrackLabel);
147 for (
unsigned i_slc = 0; i_slc < slices.size(); i_slc++) {
148 const std::vector<art::Ptr<sbn::VertexHit>> &vhits = slcVHits.at(i_slc);
151 art::FindManyP<recob::Vertex> vhitVtxs(vhits, e, fVertexChargeLabel);
152 art::FindManyP<recob::Hit> vhitHits(vhits, e, fVertexChargeLabel);
155 art::Ptr<recob::Slice> thisSlice = slices[i_slc];
157 std::vector<sbn::StubInfo> stubs;
158 for (
unsigned i_vhit = 0; i_vhit < vhits.size(); i_vhit++) {
161 const recob::Hit &thisVHitHit = *vhitHits.at(i_vhit).at(0);
163 bool passcut = (thisVHit.
dqdx >= fdQdxCut) || ((
abs(thisVHit.
wire.
Wire - thisVHit.
vtxw) < 1.) && (thisVHit.
dqdx >= fOneWiredQdxCut));
165 if (!passcut)
continue;
168 sinfo.
stub = fStubBuilder.FromVertexHit(thisSlice, thisVHit, thisVHitHit, geo, sce, clock_data, dprop, e, sinfo.
hits, sinfo.
pfp);
169 sinfo.
vhit = vhits[i_vhit];
170 sinfo.
vhit_hit = vhitHits.at(i_vhit).at(0);
172 stubs.push_back(sinfo);
177 for (
unsigned i_mrg = 0; i_mrg < fStubMergeTools.size(); i_mrg++) {
178 stubs = fStubMergeTools[i_mrg]->Merge(stubs, geo, sce, clock_data, dprop);
182 for (
unsigned i_stub = 0; i_stub < stubs.size(); i_stub++) {
185 outStubs->push_back(sinfo.
stub);
186 art::Ptr<sbn::Stub> outStub = StubPtrMaker(outStubs->size() - 1);
187 assn->addSingle(sinfo.
vhit, outStub);
188 for (
unsigned i_hit = 0; i_hit < sinfo.
hits.size(); i_hit++) {
189 hitAssn->addSingle(outStub, sinfo.
hits[i_hit]);
191 slcAssn->addSingle(outStub, thisSlice);
193 pfpAssn->addSingle(outStub, sinfo.
pfp);
199 e.put(std::move(outStubs));
200 e.put(std::move(assn));
201 e.put(std::move(hitAssn));
202 e.put(std::move(slcAssn));
203 e.put(std::move(pfpAssn));
Data product for reconstructed trajectory in space.
float dqdx
charge/pitch [#elec/cm]
Utilities related to art service access.
geo::WireID wire
Wire that the hit is on.
Declaration of signal hit object.
void produce(art::Event &e) override
WireID_t Wire
Index of the wire within its plane.
std::vector< std::unique_ptr< sbn::IStubMerge > > fStubMergeTools
Internal struct: contains information on stub and other associated data products. ...
std::vector< art::Ptr< recob::Hit > > hits
art::InputTag fTrackLabel
Access the description of detector geometry.
bool fPositionsAreSCECorrected
sbn::StubBuilder fStubBuilder
VertexStubTracker(fhicl::ParameterSet const &p)
Collection of exceptions for Geometry system.
art::InputTag fVertexChargeLabel
Data product for reconstructed trajectory in space.
art::Ptr< recob::Hit > vhit_hit
Description of geometry of one entire detector.
Declaration of cluster object.
Provides recob::Track data product.
std::vector< TCSlice > slices
art::Ptr< sbn::VertexHit > vhit
Declaration of basic channel signal object.
VertexStubTracker & operator=(VertexStubTracker const &)=delete
2D representation of charge deposited in the TDC/wire plane
Class defining a sparse vector (holes are zeroes)
art framework interface to geometry description
float vtxw
Wire of the vertex associated with this hit. Not space charge corrected. [cm].
art::Ptr< recob::PFParticle > pfp