8#include <tracking/trackFindingCDC/findlets/minimal/AxialTrackCreatorHitHough.h>
10#include <tracking/trackFindingCDC/hough/perigee/AxialLegendreLeafProcessor.h>
11#include <tracking/trackFindingCDC/hough/perigee/AxialLegendreLeafProcessor.icc.h>
12#include <tracking/trackFindingCDC/hough/perigee/StandardBinSpec.h>
14#include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
15#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
17#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
19#include <framework/core/ModuleParamList.templateDetails.h>
22using namespace TrackFindingCDC;
26 void saveBounds(std::vector<float> bounds,
const std::string& fileName)
28 std::ofstream boundsFile;
29 boundsFile.open(fileName);
30 for (
float bound : bounds) {
37 std::vector<float> loadBounds(
const std::string& fileName)
39 std::vector<float> bounds;
40 std::ifstream boundsFile;
41 std::string boundLine;
42 boundsFile.open(fileName);
43 if (boundsFile.is_open()) {
44 while (std::getline(boundsFile, boundLine)) {
45 float bound = stof(boundLine);
46 bounds.push_back(bound);
50 B2ERROR(
"Could not read bounds file");
59 return "Generates axial tracks from hits using several increasingly relaxed hough space search over phi0 and curvature.";
63 const std::string& prefix)
66 moduleParamList->
addParameter(prefixed(prefix,
"granularityLevel"),
68 "Level of divisions in the hough space.",
71 moduleParamList->
addParameter(prefixed(prefix,
"sectorLevelSkip"),
73 "Number of levels to be skipped in the hough "
74 "space on the first level to form sectors",
77 moduleParamList->
addParameter(prefixed(prefix,
"curvBounds"),
79 "Curvature bounds of the hough space. Either 2 or all discrete bounds",
82 moduleParamList->
addParameter(prefixed(prefix,
"discretePhi0Width"),
84 "Width of the phi0 bins at the lowest level of the hough space.",
87 moduleParamList->
addParameter(prefixed(prefix,
"discretePhi0Overlap"),
89 "Overlap of the phi0 bins at the lowest level of the hough space.",
92 moduleParamList->
addParameter(prefixed(prefix,
"discreteCurvWidth"),
94 "Width of the curvature bins at the lowest level of the hough space.",
97 moduleParamList->
addParameter(prefixed(prefix,
"discreteCurvOverlap"),
99 "Overlap of the curvature bins at the lowest level of the hough space.",
103 moduleParamList->
addParameter(prefixed(prefix,
"relaxationSchedule"),
105 "Relaxation schedule for the leaf processor in the hough tree. "
106 "For content of the individual parameter maps consider the parameters of the "
107 "AxialLegendreLeafProcessor",
150 std::vector<CDCTrack>& tracks)
153 std::vector<const CDCWireHit*> unusedAxialWireHits;
154 for (
const CDCWireHit* wireHit : axialWireHits) {
155 (*wireHit)->setMaskedFlag(
false);
156 if ((*wireHit)->hasTakenFlag())
continue;
157 unusedAxialWireHits.push_back(wireHit);
166 const std::string prefix =
"";
179 const std::vector<CDCTrack>& foundTracks = leafProcessor.
getTracks();
180 tracks.insert(tracks.end(), foundTracks.begin(), foundTracks.end());
192 using BinSpan = std::array<float, 2>;
193 using BinSpans = std::vector<BinSpan>;
194 std::vector<BinSpans> binSpansByLevel(granularityLevel + 1);
195 binSpansByLevel[0].push_back(BinSpan({curvSpan[0], curvSpan[1]}));
197 for (
int level = 1; level <= granularityLevel; ++level) {
198 for (
const BinSpan& binSpan : binSpansByLevel[level - 1]) {
199 const float subBinWidth = std::fabs(binSpan[1] - binSpan[0]) / 2;
200 const float middle = binSpan[0] + (binSpan[1] - binSpan[0]) / 2.0;
208 const float extension = [&]() {
209 if ((level + 7 <= granularityLevel)
211 or (std::fabs(middle) <= 0.005)) {
213 }
else if (level + 5 < granularityLevel) {
214 return subBinWidth / 4.0;
216 return subBinWidth / 8.0;
220 const float lower1 = binSpan[0] - extension;
221 const float upper1 = middle + extension;
223 const float lower2 = middle - extension;
224 const float upper2 = binSpan[1] + extension;
226 binSpansByLevel[level].push_back({lower1, upper1});
227 binSpansByLevel[level].push_back({lower2, upper2});
232 std::vector<float> result;
234 for (BinSpan& binSpan : binSpansByLevel[granularityLevel]) {
235 result.push_back(binSpan[0]);
236 result.push_back(binSpan[1]);
The Module parameter list class.
Predicate class that is feed the nodes in a WeightedHoughTree walk It decides if a node should be fur...
void setAxialWireHits(std::vector< const CDCWireHit * > axialWireHits)
Set the pool of all axial wire hits to be used in the postprocessing.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters as a module parameter list.
void beginWalk()
Function to notify the leaf processor about changes in parameters before a new walk.
const std::vector< CDCTrack > & getTracks() const
Getter for the tracks.
const double m_curlCurv
Curvature below which particles from IP do not leave the CDC.
static const int c_curvDivisions
Fixed parameter: Number of divisions in the curv direction.
void apply(const std::vector< const CDCWireHit * > &axialWireHits, std::vector< CDCTrack > &tracks) final
Generates the tracks from the given segments into the output argument.
std::unique_ptr< SimpleRLTaggedWireHitPhi0CurvHough > m_houghTree
The hough space tree search.
void initialize() final
Initialize the findlet before event processing.
std::vector< ParameterVariantMap > m_param_relaxationSchedule
Parameter: Relaxation schedule for the leaf processor in the hough tree.
int m_param_sectorLevelSkip
Parameter: Number of levels to be skipped in the hough space on the first level to form sectors.
std::string getDescription() final
Short description of the findlet.
int m_param_granularityLevel
Parameter: Level of divisions in the hough space.
int m_param_discretePhi0Width
Parameter: Width of the phi0 bins at the highest level of the hough space.
static std::vector< float > getDefaultCurvBounds(std::array< float, 2 > curvSpan, int granularityLevel)
Get a series of parameters to be set for each pass over the rough hough space.
std::vector< float > m_param_curvBounds
Parameter: hough bounds.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
int m_param_discreteCurvOverlap
Parameter: Overlap of the curvature bins at the highest level of the hough space.
static const int c_phi0Divisions
Fixed parameter: Number of divisions in the phi0 direction.
void terminate() final
Cleanup the findlet after event processing.
int m_param_discreteCurvWidth
Parameter: Width of the curvature bins at the highest level of the hough space.
int m_param_discretePhi0Overlap
Parameter: Overlap of the phi0 bins at the highest level of the hough space.
Class representing a hit wire in the central drift chamber.
void initialize() override
void terminate() override
Strategy to construct discrete curve points from discrete overlap specifications.
DiscreteCurv::Array constructArray() const
Construct the array of discrete curve positions.
Strategy to construct discrete phi0 points from discrete overlap specifications.
DiscretePhi0::Array constructArray() const
Construct the array of discrete phi0 positions.
int getNOverlap() const
Getter for the overlap in discrete number of positions.
typename Super::Node Node
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 update(ModuleParamList *moduleParamList, const std::map< std::string, boost::variant< T... > > &valuesByName)
Transfer all the parameters from the map boost:variant values to the module parameter list.