8#include <tracking/trackFindingCDC/findlets/minimal/FacetCreator.h>
10#include <tracking/trackingUtilities/eventdata/segments/CDCWireHitCluster.h>
11#include <tracking/trackingUtilities/eventdata/hits/CDCFacet.h>
12#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
14#include <tracking/trackingUtilities/filters/base/RelationFilterUtil.h>
15#include <tracking/trackFindingCDC/fitting/FacetFitter.h>
17#include <tracking/trackingUtilities/utilities/VectorRange.h>
18#include <tracking/trackingUtilities/utilities/StringManipulation.h>
20#include <framework/core/ModuleParamList.templateDetails.h>
27using namespace TrackFindingCDC;
28using namespace TrackingUtilities;
38 return "Creates hit triplet (facets) from each cluster filtered by a acceptance criterion.";
47 moduleParamList->
addParameter(prefixed(prefix,
"updateDriftLength"),
49 "Switch to reestimate the drift length",
52 moduleParamList->
addParameter(prefixed(prefix,
"leastSquareFit"),
54 "Switch to fit the facet with the least square method "
55 "for drift length estimation",
59void FacetCreator::apply(
const std::vector<CDCWireHitCluster>& inputClusters, std::vector<CDCFacet>& facets)
65 if (cluster.getBackgroundFlag()) {
68 B2ASSERT(
"Expect the clusters to be sorted", std::is_sorted(cluster.begin(), cluster.end()));
71 const std::vector<CDCWireHit*>& wireHits = cluster;
77 B2ASSERT(
"Wire neighborhood is not symmetric. Check the geometry.",
81 std::size_t nBefore = facets.size();
83 std::size_t nAfter = facets.size();
85 VectorRange<CDCFacet> facetsInCluster(facets.begin() + nBefore, facets.begin() + nAfter);
87 std::sort(facetsInCluster.
begin(), facetsInCluster.
end());
89 B2ASSERT(
"Expected all facets to be different",
90 std::adjacent_find(facetsInCluster.
begin(), facetsInCluster.
end()) ==
91 facetsInCluster.
end());
93 for (
CDCFacet& facet : facetsInCluster) {
94 facet.setICluster(iCluster);
101 std::vector<CDCFacet>& facets)
103 for (
const CDCWireHit* ptrMiddleWireHit : wireHits) {
104 if (not ptrMiddleWireHit)
continue;
105 const CDCWireHit& middleWireHit = *ptrMiddleWireHit;
108 const auto neighbors = asRange(
109 std::equal_range(wireHitRelations.begin(), wireHitRelations.end(), ptrMiddleWireHit));
112 const CDCWireHit* ptrStartWireHit(startWireHitRelation.getTo());
114 if (not ptrStartWireHit)
continue;
115 const CDCWireHit& startWireHit = *ptrStartWireHit;
119 const CDCWireHit* ptrEndWireHit(endWireHitRelation.getTo());
121 if (not ptrEndWireHit)
continue;
122 const CDCWireHit& endWireHit = *ptrEndWireHit;
126 if (ptrStartWireHit->isOnWire(ptrEndWireHit->getWire()))
continue;
137 std::vector<CDCFacet>& facets)
140 CDCRLWireHit startRLWireHit(&startWireHit, ERightLeft::c_Left);
141 CDCRLWireHit middleRLWireHit(&middleWireHit, ERightLeft::c_Left);
142 CDCRLWireHit endRLWireHit(&endWireHit, ERightLeft::c_Left);
145 for (ERightLeft startRLInfo : {ERightLeft::c_Left, ERightLeft::c_Right}) {
147 for (ERightLeft middleRLInfo : {ERightLeft::c_Left, ERightLeft::c_Right}) {
149 for (ERightLeft endRLInfo : {ERightLeft::c_Left, ERightLeft::c_Right}) {
159 if (std::isnan(feasibleWeight))
continue;
181 if (not std::isnan(weight)) {
183 facets.insert(facets.end(), facet);
The Module parameter list class.
DriftLengthEstimator m_driftLengthEstimator
Instance of the drift length estimator to be used.
void createFacetsForHitTriple(const TrackingUtilities::CDCWireHit &startWireHit, const TrackingUtilities::CDCWireHit &middleWireHit, const TrackingUtilities::CDCWireHit &endWireHit, std::vector< TrackingUtilities::CDCFacet > &facets)
Generates reconstruted facets on the three given wire hits by hypothesizing over the 8 left right pas...
BridgingWireHitRelationFilter m_wireHitRelationFilter
The filter for the hit neighborhood.
bool m_param_feasibleRLOnly
Parameter : Switch to apply the rl feasibility cut.
void apply(const std::vector< TrackingUtilities::CDCWireHitCluster > &inputClusters, std::vector< TrackingUtilities::CDCFacet > &facets) final
Central function creating the hit triplets from the clusters.
bool m_param_leastSquareFit
Parameter : Switch to fit the facet with least square method for the drift length update.
std::string getDescription() final
Short description of the findlet.
std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCWireHit > > m_wireHitRelations
Memory for the wire hit neighborhood in within a cluster.
ChooseableFacetFilter m_facetFilter
The filter to be used for the facet generation.
bool m_param_updateDriftLength
Parameter : Switch to reestimate the drift length.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
FeasibleRLFacetFilter m_feasibleRLFacetFilter
The feasibility filter for the right left passage information.
void createFacets(const std::vector< TrackingUtilities::CDCWireHit * > &wireHits, const std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCWireHit > > &wireHitRelations, std::vector< TrackingUtilities::CDCFacet > &facets)
Generates facets on the given wire hits generating neighboring triples of hits.
FacetCreator()
Constructor adding the filter as a subordinary processing signal listener.
static double fit(const TrackingUtilities::CDCFacet &facet, int nSteps=100)
Fits a proper line to facet and returns the chi2.
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
void setCellWeight(Weight weight)
Setter for the cell weight.
Class representing a triple of neighboring oriented wire with additional trajectory information.
void adjustFitLine() const
Adjusts the contained fit line to touch such that it touches the first and third hit.
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
void invalidateFitLine()
Clear all information in the fit.
void setEndRLInfo(const ERightLeft endRLInfo)
Setter for the right left passage information of the third oriented wire hit.
CDCRLWireHit & getStartRLWireHit()
Getter for the first oriented wire hit.
void setMiddleRLInfo(const ERightLeft middleRLInfo)
Setter for the right left passage information of the second oriented wire hit.
CDCRLWireHit & getEndRLWireHit()
Getter for the third oriented wire hit.
CDCRLWireHit & getMiddleRLWireHit()
Getter for the second oriented wire hit.
void setStartRLInfo(const ERightLeft startRLInfo)
Setter for the right left passage information of the first oriented wire hit.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
void setRefDriftLength(double driftLength)
Setter for the drift length at the reference position of the wire.
An aggregation of CDCWireHits.
Class representing a hit wire in the central drift chamber.
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Iterator begin() const
Begin of the range for range based for.
Iterator end() const
End of the range for range based for.
A parameter line including including an line covariance matrix which is interpreted as located in the...
Type for two related objects with a weight.
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.
static void appendUsing(ARelationFilter &relationFilter, const std::vector< AObject * > &froms, const std::vector< AObject * > &tos, std::vector< WeightedRelation< AObject > > &weightedRelations, unsigned int maximumNumberOfRelations=std::numeric_limits< unsigned int >::max())
Appends relations between elements in the given AItems using the ARelationFilter.
static bool areSymmetric(const AWeightedRelations &weightedRelations)
Checks for the symmetry of a range of weighted relations Explicitly checks for each weighted relation...