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)
std::vector< geo::PlaneID > plane
The plane ID.
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)
bool fRemoveDuplicateMerges