Skip to content

Commit 0a97d9c

Browse files
committed
SimpleCut: clang-tidy, decouple from HelperFunctions
1 parent dfa8154 commit 0a97d9c

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

infra/SimpleCut.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
Authors: Viktor Klochkov, Ilya Selyuzhenkov */
44
#include "SimpleCut.hpp"
55

6-
#include "HelperFunctions.hpp"
7-
86
#include <iostream>
97

108
namespace AnalysisTree {
@@ -30,19 +28,19 @@ bool operator==(const SimpleCut& that, const SimpleCut& other) {
3028
}
3129

3230
SimpleCut RangeCut(const std::string& variable_name, double lo, double hi, const std::string& title) {
33-
return SimpleCut(Variable::FromString(variable_name), lo, hi, title);
31+
return {Variable::FromString(variable_name), lo, hi, title};
3432
}
3533

3634
SimpleCut EqualsCut(const std::string& variable_name, int value, const std::string& title) {
37-
return SimpleCut(Variable::FromString(variable_name), value, title);
35+
return {Variable::FromString(variable_name), value, title};
3836
}
3937

4038
SimpleCut RangeCut(const Variable& var, double lo, double hi, const std::string& title) {
41-
return SimpleCut(var, lo, hi, title);
39+
return {var, lo, hi, title};
4240
}
4341

4442
SimpleCut EqualsCut(const Variable& var, int value, const std::string& title) {
45-
return SimpleCut(var, value, title);
43+
return {var, value, title};
4644
}
4745

4846
SimpleCut OpenCut(const std::string& branchName, const std::string& title) {
@@ -53,7 +51,7 @@ SimpleCut::SimpleCut(const Variable& var, int value, std::string title) : title_
5351
vars_.emplace_back(var);
5452
lambda_ = [value](std::vector<double>& vars) { return vars[0] <= value + SmallNumber && vars[0] >= value - SmallNumber; };
5553
FillBranchNames();
56-
const std::string stringForHash = var.GetName() + HelperFunctions::ToStringWithPrecision(value, 6) + title_;
54+
const std::string stringForHash = var.GetName() + std::to_string(value) + title_;
5755
std::hash<std::string> hasher;
5856
hash_ = hasher(stringForHash);
5957
}
@@ -62,7 +60,7 @@ SimpleCut::SimpleCut(const Variable& var, double min, double max, std::string ti
6260
vars_.emplace_back(var);
6361
lambda_ = [max, min](std::vector<double>& vars) { return vars[0] <= max && vars[0] >= min; };
6462
FillBranchNames();
65-
const std::string stringForHash = var.GetName() + HelperFunctions::ToStringWithPrecision(min, 6) + HelperFunctions::ToStringWithPrecision(max, 6) + title_;
63+
const std::string stringForHash = var.GetName() + std::to_string(min) + std::to_string(max) + title_;
6664
std::hash<std::string> hasher;
6765
hash_ = hasher(stringForHash);
6866
}
@@ -80,8 +78,8 @@ bool SimpleCut::Apply(std::vector<const BranchChannel*>& bch, std::vector<size_t
8078
}
8179

8280
bool SimpleCut::Apply(const BranchChannel& a, size_t a_id, const BranchChannel& b, size_t b_id) const {
83-
BranchChannel* a_ptr = new BranchChannel(std::move(a));
84-
BranchChannel* b_ptr = new BranchChannel(std::move(b));
81+
auto* a_ptr = new BranchChannel(a);
82+
auto* b_ptr = new BranchChannel(b);
8583
std::vector<const BranchChannel*> brch_vec{a_ptr, b_ptr};
8684
std::vector<size_t> id_vec{a_id, b_id};
8785
bool result = Apply(brch_vec, id_vec);

0 commit comments

Comments
 (0)