Skip to content

Commit

Permalink
fix: Hough Transform first implementation clang-tidy (#1691)
Browse files Browse the repository at this point in the history
based on #1305

clang tidy fixes
  • Loading branch information
andiwand authored Nov 25, 2022
1 parent 980f9ef commit c7d009f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,86 +31,97 @@ using ResultBool = Acts::Result<bool>;
using ResultUnsigned = Acts::Result<unsigned>;

ResultDouble fieldCorrectionDefault(unsigned region, double y, double r) {
if (region == 999)
if (region == 999) {
return y + r; // this should not be found, for now this is a dummy to show
// what one *could* do
}
return ResultDouble::success(0.0);
}

ResultUnsigned findLayerIDDefault(double r) {
if (r < 50)
if (r < 50) {
return ResultUnsigned::success(0);
else if (r < 100)
} else if (r < 100) {
return ResultUnsigned::success(1);
else if (r < 150)
} else if (r < 150) {
return ResultUnsigned::success(2);
else if (r < 200)
} else if (r < 200) {
return ResultUnsigned::success(3);
else if (r < 300)
} else if (r < 300) {
return ResultUnsigned::success(4);
else if (r < 400)
} else if (r < 400) {
return ResultUnsigned::success(5);
else if (r < 550)
} else if (r < 550) {
return ResultUnsigned::success(6);
else if (r < 700)
} else if (r < 700) {
return ResultUnsigned::success(7);
else if (r < 900)
} else if (r < 900) {
return ResultUnsigned::success(8);
else if (r < 1100)
} else if (r < 1100) {
return ResultUnsigned::success(9);
}
return ResultUnsigned::failure(
HoughError::Failure); /// shouldn't be here, this won't be used
}

// default with two slices, one for negative and one for positive z, counting
// some small overlaps, and -1 means "just take everything"
ResultBool inSliceDefault(double z, unsigned layer, int slice) {
if (slice == -1)
if (slice == -1) {
return ResultBool::success(true);
}

double absz = abs(z);
if (slice == 0 && z > 50)
if (slice == 0 && z > 50) {
return ResultBool::success(false);
else if (slice == 1 && z < -50)
} else if (slice == 1 && z < -50) {
return ResultBool::success(false);
else {
} else {
if (layer <= 3) {
if (absz < 200)
if (absz < 200) {
return ResultBool::success(true);
else
} else {
return ResultBool::success(false);
}
} else if (layer == 4) {
if (absz < 300)
if (absz < 300) {
return ResultBool::success(true);
else
} else {
return ResultBool::success(false);
}
} else if (layer == 5) {
if (absz < 400)
if (absz < 400) {
return ResultBool::success(true);
else
} else {
return ResultBool::success(false);
}
} else if (layer == 6) {
if (absz < 600)
if (absz < 600) {
return ResultBool::success(true);
else
} else {
return ResultBool::success(false);
}
} else if (layer == 7) {
if (absz < 700)
if (absz < 700) {
return ResultBool::success(true);
else
} else {
return ResultBool::success(false);
}
} else if (layer == 8) {
if (absz < 800)
if (absz < 800) {
return ResultBool::success(true);
else
} else {
return ResultBool::success(false);
}
} else if (layer == 9) {
if (absz < 1100)
if (absz < 1100) {
return ResultBool::success(true);
else
} else {
return ResultBool::success(false);
} else
}
} else {
return ResultBool::success(false);
}
}
}
} // namespace DefaultHoughFunctions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class HoughTransformSeeder final : public BareAlgorithm {
///
/// @param txt is the algorithm context with event information
/// @return a process code indication success or failure
ProcessCode execute(const AlgorithmContext& ctx) const final override;
ProcessCode execute(const AlgorithmContext& ctx) const final;

/// Const access to the config
const Config& config() const { return m_cfg; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ class vector2D {
}

size_t size(int dim) const {
if (dim == 0)
if (dim == 0) {
return m_d1;
if (dim == 1)
}
if (dim == 1) {
return m_d2;
else {
} else {
ACTS_ERROR("vector2D: Argument to size() must be 0 or 1");
return 0;
}
Expand Down
7 changes: 4 additions & 3 deletions Examples/Run/Reconstruction/Common/HoughExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
using namespace Acts::UnitLiterals;
using namespace ActsExamples;

int runHoughExample(int argc, char* argv[],
std::shared_ptr<ActsExamples::IBaseDetector> detector) {
int runHoughExample(
int argc, char* argv[],
const std::shared_ptr<ActsExamples::IBaseDetector>& detector) {
// Setup and parse options
auto desc = Options::makeDefaultOptions();
Options::addSequencerOptions(desc);
Expand Down Expand Up @@ -70,7 +71,7 @@ int runHoughExample(int argc, char* argv[],
std::make_shared<RandomNumbers>(Options::readRandomNumbersConfig(vm));

// Add the decorator to the sequencer
for (auto cdr : contextDecorators) {
for (const auto& cdr : contextDecorators) {
sequencer.addContextDecorator(cdr);
}

Expand Down
5 changes: 3 additions & 2 deletions Examples/Run/Reconstruction/Common/HoughExample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ class IBaseDetector;
/// @param argc the number of argumetns of the call
/// @param argv the argument list
/// @param detector The detector descriptor instance
int runHoughExample(int argc, char* argv[],
std::shared_ptr<ActsExamples::IBaseDetector> detector);
int runHoughExample(
int argc, char* argv[],
const std::shared_ptr<ActsExamples::IBaseDetector>& detector);

0 comments on commit c7d009f

Please sign in to comment.