6 #include "art/Framework/Principal/Event.h"
7 #include "art/Framework/Principal/Handle.h"
8 #include "art/Framework/Services/Registry/ServiceHandle.h"
9 #include "art/Persistency/Common/PtrMaker.h"
10 #include "art/Utilities/ToolMacros.h"
11 #include "cetlib/cpu_timer.h"
12 #include "fhiclcpp/ParameterSet.h"
13 #include "messagefacility/MessageLogger/MessageLogger.h"
45 std::vector<sbn::StubInfo>
Merge(
const std::vector<sbn::StubInfo> &stubs,
66 fMaxMergeTOff(pset.
get<double>(
"MaxMergeTOff")),
67 fMaxMergeQOff(pset.
get<double>(
"MaxMergeQOff")),
68 fRemoveDuplicateMerges(pset.
get<
bool>(
"RemoveDuplicateMerges")),
69 fSaveOldStubs(pset.
get<
bool>(
"SaveOldStubs"))
80 if (A_nhit != B_nhit)
return A_nhit > B_nhit;
83 return ((A.
vhit_hit->WireID().Plane + 1) % 3) < ((B.
vhit_hit->WireID().Plane + 1) % 3);
152 std::vector<MergeInfo> merges;
155 for (
unsigned i_stub = 0; i_stub < stubs.size(); i_stub++) {
156 for (
unsigned j_stub = 0; j_stub < stubs.size(); j_stub++) {
167 merges.push_back({toff, qoff, i_stub, j_stub});
174 std::sort(merges.begin(), merges.end(), [](
auto const &lhs,
auto const &rhs) {
return lhs.toff < rhs.toff;});
177 std::set<unsigned> hasmerged;
180 std::set<unsigned> dontsave;
183 std::vector<sbn::StubInfo> ret;
185 for (
unsigned i_mrg = 0; i_mrg < merges.size(); i_mrg++) {
186 const MergeInfo &thismrg = merges[i_mrg];
188 if (!hasmerged.count(thismrg.i) && !hasmerged.count(thismrg.j)) {
189 ret.push_back(
MergeStubs(stubs[thismrg.i], stubs[thismrg.j], geo, sce, dprop));
190 hasmerged.insert(thismrg.i);
191 hasmerged.insert(thismrg.j);
194 dontsave.insert(thismrg.i);
197 dontsave.insert(thismrg.j);
203 for (
unsigned i_stub = 0; i_stub < stubs.size(); i_stub++) {
204 if (
fSaveOldStubs || (!hasmerged.count(i_stub) && !dontsave.count(i_stub))) {
205 ret.push_back(stubs[i_stub]);
float StubChargeOffset(const sbn::StubInfo &A, const sbn::StubInfo &B)
Difference of the total charge between two stubs.
float StubTimeOffset(const sbn::StubInfo &A, const sbn::StubInfo &B, const detinfo::DetectorClocksData &dclock, const detinfo::DetectorPropertiesData &dprop)
Abstract interface intended for art tools which take a list of stubs and return a new list with some ...
Utilities related to art service access.
std::vector< geo::PlaneID > plane
The plane ID.
std::vector< std::vector< StubHit > > hits
Hits on each plane. Ordered vtx->end.
geo::Point_t end
End of Stub. Space charge corrected. [cm].
Internal struct: contains information on stub and other associated data products. ...
sbn::StubInfo MergeStubs(const sbn::StubInfo &A, const sbn::StubInfo &B, const geo::GeometryCore *geo, const spacecharge::SpaceCharge *sce, const detinfo::DetectorPropertiesData &dprop)
geo::Point_t vtx
Interaction Vertex / Start of Stub. Space charge corrected. [cm].
bool fRemoveDuplicateMerges
std::vector< float > vtx_w
Wire coordinate of the vertex on this plane.
std::vector< art::Ptr< recob::Hit > > hits
Access the description of detector geometry.
std::vector< short > hit_w
Wire of the end point hit on this plane.
art::Ptr< recob::Hit > vhit_hit
Description of geometry of one entire detector.
float efield_end
The E-Field at the stub end point.
float efield_vtx
The E-Field at the reconstructed vertex.
Provides a base class aware of world box coordinates.
TwoPlaneStubMerge(fhicl::ParameterSet const &pset)
Constructor.
art::Ptr< sbn::VertexHit > vhit
Contains all timing reference information for the detector.
geo::Point_t TwoStubEndPosition(const sbn::StubInfo &A, const sbn::StubInfo &B, const geo::GeometryCore *geo, const spacecharge::SpaceCharge *sce, const detinfo::DetectorPropertiesData &dprop)
Returns an updated end position of a stub after merging across two planes.
std::vector< sbn::StubInfo > Merge(const std::vector< sbn::StubInfo > &stubs, const geo::GeometryCore *geo, const spacecharge::SpaceCharge *sce, const detinfo::DetectorClocksData &dclock, const detinfo::DetectorPropertiesData &dprop) override
double GetEfield(const detinfo::DetectorPropertiesData &dprop, const spacecharge::SpaceCharge *sce, geo::Point_t loc, geo::TPCID TPC, bool correct_loc_sce, float xsign=1.)
Get the E-Field in the presence of space charge.
std::vector< float > trkpitch
Pitch of the matched track on each wire [cm].
int CoreNHit(unsigned plane_index=0) const
Returns the number of hits along the core of the stub on the given plane index.
Art tool for merging stubs across planes.
std::vector< float > pitch
Pitch of stub on each wire [cm].
art framework interface to geometry description
bool SortStubs(const sbn::StubInfo &A, const sbn::StubInfo &B)
art::Ptr< recob::PFParticle > pfp