8 #include <tracking/trackFindingCDC/findlets/minimal/SuperClusterCreator.h>
10 #include <tracking/trackFindingCDC/eventdata/segments/CDCWireHitCluster.h>
11 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
13 #include <tracking/trackFindingCDC/topology/CDCWireLayer.h>
14 #include <tracking/trackFindingCDC/topology/CDCWire.h>
16 #include <tracking/trackFindingCDC/filters/base/RelationFilterUtil.h>
18 #include <tracking/trackFindingCDC/utilities/Functional.h>
19 #include <tracking/trackFindingCDC/utilities/Algorithms.h>
20 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
22 #include <framework/core/ModuleParamList.templateDetails.h>
25 using namespace TrackFindingCDC;
34 return "Groups the wire hits into super cluster by expanding the secondary wire "
40 moduleParamList->
addParameter(prefixed(prefix,
"expandOverApogeeGap"),
42 "Expand the super clusters over the typical gap at the apogee of the trajectory",
49 std::vector<CDCWireHitCluster>& outputSuperClusters)
54 auto wireHitsByLayer =
55 adjacent_groupby(inputWireHits.begin(), inputWireHits.end(), [](
const CDCWireHit & wireHit) {
56 return wireHit.getWireID().getILayer();
59 for (
const auto& wireHitsInLayer : wireHitsByLayer) {
61 const int nWires = wireLayer.
size();
68 unique_ranges(wireHitsInLayer.begin(), wireHitsInLayer.end(), sameWireHitChain);
72 nWireHits += wireHitChain.size();
74 assert(nWireHits == wireHitsInLayer.size());
79 if (wireHitChains.
size() > 1) {
80 if (wireHitChains.
front().front().getWire().isPrimaryNeighborWith(
81 wireHitChains.
back().back().getWire())) {
84 int wrapAroundChainSize = wireHitChains.
front().size() + wireHitChains.
back().size();
85 if (wrapAroundChainSize >= 5) {
88 frontWrapChain = wireHitChains.
front();
89 frontWrapChain.first = frontWrapChain.
end() - wrapAroundChainSize;
91 backWrapChain = wireHitChains.
back();
92 backWrapChain.second = backWrapChain.
begin() + wrapAroundChainSize;
94 wireHitChains.erase(wireHitChains.
begin());
95 wireHitChains.pop_back();
100 auto itLastChain = std::remove_if(wireHitChains.
begin(), wireHitChains.
end(),
Size() < 5u);
101 wireHitChains.erase(itLastChain, wireHitChains.
end());
102 if (wireHitChains.
empty())
continue;
107 if (iWireDelta < 0) iWireDelta += nWires;
108 if (iWireDelta <
static_cast<int>(lhs.size() + rhs.size())) {
116 std::adjacent_find(wireHitChains.
begin(), wireHitChains.
end(), connectWireHitChains);
118 if (not frontWrapChain.
empty()) {
119 connectWireHitChains(frontWrapChain, wireHitChains.
front());
121 if (not backWrapChain.
empty()) {
122 connectWireHitChains(wireHitChains.
back(), backWrapChain);
124 if (backWrapChain.
empty() and frontWrapChain.
empty()) {
125 connectWireHitChains(wireHitChains.
back(), wireHitChains.
front());
131 const std::vector<CDCWireHit*> wireHitPtrs = as_pointers<CDCWireHit>(inputWireHits);
136 B2ASSERT(
"Expect wire hit neighborhood to be symmetric ",
141 int iSuperCluster = -1;
144 superCluster.setISuperCluster(iSuperCluster);
146 wireHit->setISuperCluster(iSuperCluster);
148 std::sort(superCluster.begin(), superCluster.end());
The Module parameter list class.
An aggregation of CDCWireHits.
Class representing a hit wire in the central drift chamber.
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
Class representating a sense wire layer in the central drift chamber.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
A pair of iterators usable with the range base for loop.
Iterator begin() const
Begin of the range for range based for.
Iterator end() const
End of the range for range based for.
bool empty() const
Checks if the begin equals the end iterator, hence if the range is empty.
Reference back() const
Returns the derefenced iterator before end()
Reference front() const
Returns the derefenced iterator at begin()
std::size_t size() const
Returns the total number of objects in this range.
void apply(std::vector< CDCWireHit > &inputWireHits, std::vector< CDCWireHitCluster > &outputSuperClusters) final
Main algorithm applying the cluster refinement.
bool m_param_expandOverApogeeGap
Parameter : Expand the super clusters over the typical gap at the apogee of the trajectory.
std::vector< WeightedRelation< CDCWireHit > > m_wireHitRelations
Memory for the wire hit neighborhood in a cluster.
SuperClusterCreator()
Constructor.
std::string getDescription() final
Short description of the findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
Clusterizer< CDCWireHit, CDCWireHitCluster > m_wirehitClusterizer
Instance of the hit cluster generator.
WholeWireHitRelationFilter m_wireHitRelationFilter
Wire hit neighborhood relation filter.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
unsigned short getIWire() const
Getter for wire within the layer.
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.
Functor to get the .size() from an abitrary objects.
Utility structure with functions related to weighted relations.