10#include <tracking/trackFindingCDC/findlets/base/Findlet.h>
11#include <tracking/ckf/cdc/entities/CDCCKFResult.h>
13#include <tracking/trackFindingCDC/filters/base/ChooseableFilter.h>
14#include <tracking/ckf/cdc/filters/paths/CDCPathFilterFactory.h>
16#include <tracking/ckf/cdc/filters/pathPairs/CDCPathPairFilterFactory.h>
17#include <tracking/trackFindingCDC/filters/base/ChooseableFilter.icc.h>
19#include <ecl/dataobjects/ECLShower.h>
21#include <Math/VectorUtil.h>
42 m_filter_badTracks.exposeParameters(moduleParamList, TrackFindingCDC::prefixed(
"badTracks", prefix));
44 m_filter_duplicateSeed.exposeParameters(moduleParamList, TrackFindingCDC::prefixed(
"duplicateSeed", prefix));
46 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"duplicateSeed_maxPhi"),
48 "Seeds within this dPhi can be considered as duplicates (-1 to neglect)",
51 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"duplicateSeed_maxTheta"),
53 "Seeds within this dTheta can be considered as duplicates (-1 to neglect)",
58 void apply(std::vector<CDCCKFResult>& results)
override
60 B2DEBUG(29,
"CDCCKFDuplicateRemover: " << results.size() <<
" paths created (might be without any hits)");
62 std::vector<CDCCKFResult> goodResults;
65 TrackFindingCDC::Weight weight;
66 std::unordered_map<double, CDCCKFResult> resultToWeightList;
67 for (
const auto& result : results) {
69 if (not std::isnan(weight)) {
70 goodResults.push_back(result);
74 int n_goodresults = goodResults.size();
76 B2DEBUG(29,
"CDCCKFDuplicateRemover: " << goodResults.size() <<
" paths created (after filtering)");
78 if (n_goodresults > 1) {
79 for (
const auto& result : goodResults) {
80 B2DEBUG(29,
"charge = " << result.front().getSeed()->getChargeSeed() <<
"; "
81 <<
"theta = " << result.front().getSeed()->getPositionSeed().Theta() * 180. / M_PI <<
"; "
82 << (result.size() - 1) <<
" hits (" << result.at(1).getWireHit()->getWire().getICLayer() <<
"->" <<
83 result.back().getWireHit()->getWire().getICLayer() <<
"); "
84 <<
"r/z = " << result.front().getSeed()->getPositionSeed().Rho() <<
"; " << result.front().getSeed()->getPositionSeed().Z());
89 auto iter = goodResults.begin();
90 while (iter < goodResults.end()) {
91 auto iter2 = iter + 1;
92 bool increaseIter =
true;
93 while (iter2 < goodResults.end()) {
99 iter2 = goodResults.erase(iter2);
101 iter = goodResults.erase(iter);
102 increaseIter =
false;
114 B2DEBUG(29,
"CDCCKFDuplicateRemover: " << goodResults.size() <<
" paths created (after duplicates)");
116 if (n_goodresults > 1) {
117 for (
const auto& result : goodResults) {
118 B2DEBUG(29,
"charge = " << result.front().getSeed()->getChargeSeed() <<
"; "
119 <<
"theta = " << result.front().getSeed()->getPositionSeed().Theta() * 180. / M_PI <<
"; "
120 << (result.size() - 1) <<
" hits (" << result.at(1).getWireHit()->getWire().getICLayer() <<
"->" <<
121 result.back().getWireHit()->getWire().getICLayer() <<
"); "
122 <<
"r/z = " << result.front().getSeed()->getPositionSeed().Rho() <<
"; " << result.front().getSeed()->getPositionSeed().Z());
128 iter = goodResults.begin();
129 while (iter < goodResults.end()) {
130 double phiClus = iter->front().getSeed()->getPositionSeed().Phi();
131 double thetaClus = iter->front().getSeed()->getPositionSeed().Theta();
133 auto iter2 = iter + 1;
134 bool increaseIter =
true;
135 while (iter2 < goodResults.end()) {
138 if (std::abs(ROOT::Math::VectorUtil::Phi_mpi_pi(iter2->front().getSeed()->getPositionSeed().Phi() - phiClus)) <
duplicateSeed_maxPhi
143 B2DEBUG(29,
"Keeping both tracks");
146 B2DEBUG(29,
"Duplicate hits found");
149 iter2 = goodResults.erase(iter2);
151 iter = goodResults.erase(iter);
152 increaseIter =
false;
165 results = goodResults;
167 B2DEBUG(29,
"CDCCKFDuplicateRemover: " << results.size() <<
" paths created (after merging)");
169 if (n_goodresults > 1) {
170 for (
const auto& result : results) {
171 B2DEBUG(29,
"charge = " << result.front().getSeed()->getChargeSeed() <<
"; "
172 <<
"theta = " << result.front().getSeed()->getPositionSeed().Theta() * 180. / M_PI <<
"; "
173 << (result.size() - 1) <<
" hits (" << result.at(1).getWireHit()->getWire().getICLayer() <<
"->" <<
174 result.back().getWireHit()->getWire().getICLayer() <<
"); "
175 <<
"r/z = " << result.front().getSeed()->getPositionSeed().Rho() <<
"; " << result.front().getSeed()->getPositionSeed().Z());
Remove duplicate paths created from ECLShowers These typically come from the seeding with two charge ...
TrackFindingCDC::ChooseableFilter< CDCPathPairFilterFactory > m_filter_duplicateTrack
Filter to remove duplicates from helix extrapolation (2 charge assumptions)
TrackFindingCDC::ChooseableFilter< CDCPathPairFilterFactory > m_filter_duplicateSeed
Merge duplicate paths (mostly seeds from Bremstrahlung)
TrackFindingCDC::ChooseableFilter< CDCPathFilterFactory > m_filter_badTracks
Filter to remove badly reconstructed tracks (e.g. wrongly assigned charge)
double duplicateSeed_maxPhi
Seeds within this dPhi can be considered as duplicates.
void apply(std::vector< CDCCKFResult > &results) override
main method of the findlet, merges and filters paths
double duplicateSeed_maxTheta
Seeds within this dTheta can be considered as duplicates.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Class to store ECL Showers.
The Module parameter list class.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Convenvience wrapper to setup a Chooseable filter from a specific factory object.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.