Skip to content

Commit 4bbf64a

Browse files
committed
get rid of compiler warnings
1 parent 9aea348 commit 4bbf64a

File tree

10 files changed

+25
-25
lines changed

10 files changed

+25
-25
lines changed

core/BranchConfig.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void BranchConfig::GenerateId() {
1414
id_ = id_hasher(name_);
1515
}
1616

17-
BranchConfig::BranchConfig(std::string name, DetType type, std::string title) : name_(std::move(name)), type_(type), title_(std::move(title)) {
17+
BranchConfig::BranchConfig(std::string name, DetType type, std::string title) : name_(std::move(name)), title_(std::move(title)), type_(type) {
1818
GenerateId();
1919

2020
if (type_ == DetType::kTrack) {
@@ -156,12 +156,12 @@ void VectorConfig<T>::Print() const {
156156
std::vector<std::string> result;
157157
std::vector<int> newlinepositions{-1};
158158
int it{0};
159-
while (it < std::string::npos) {
159+
while (it < static_cast<int>(std::string::npos)) {
160160
it = input.find("\n", it + 1);
161161
newlinepositions.emplace_back(it);
162162
}
163163
newlinepositions.back() = input.size();
164-
for (int ip = 0; ip < newlinepositions.size() - 1; ++ip) {
164+
for (int ip = 0; ip < static_cast<int>(newlinepositions.size()) - 1; ++ip) {
165165
result.emplace_back(input.substr(newlinepositions.at(ip) + 1, newlinepositions.at(ip + 1) - newlinepositions.at(ip) - 1));
166166
}
167167
return result;
@@ -174,7 +174,7 @@ void VectorConfig<T>::Print() const {
174174
} else {
175175
auto est = SplitString(entry.second.title_);
176176
print_row({{std::to_string(entry.second.id_), 10}, {entry.first, name_strlen}, {est.at(0), 50}});
177-
for (int iest = 1; iest < est.size(); ++iest) {
177+
for (int iest = 1; iest < static_cast<int>(est.size()); ++iest) {
178178
print_row({{"", 10}, {"", name_strlen}, {est.at(iest), 50}});
179179
}
180180
}

core/Configuration.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ namespace AnalysisTree {
1919

2020
void Configuration::Streamer(TBuffer& rb) {
2121
if (rb.IsReading()) {
22-
bool read_ok = false;
2322
UInt_t rs = 0, rc = 0;
2423
auto version_from_file = rb.ReadVersion(&rs, &rc, Configuration::Class());
2524
if (version_from_file == Class()->GetClassVersion()) {
2625
Configuration::Class()->ReadBuffer(rb, this, version_from_file, rs, rc);
2726
// populate the transient field
2827
this->matches_index_ = MakeMatchingIndex(matches_);
29-
read_ok = true;
3028
} else if (version_from_file == 3) {
3129
// below structure description for version 3 of this class
3230
Warning(__func__, "Reading AnalysisTree::Configuration of version %d in compatibility mode. "
@@ -40,14 +38,12 @@ void Configuration::Streamer(TBuffer& rb) {
4038
this->matches_ = MakeMatchConfigsFromIndex(conf_v3.matches_);
4139
// populate the transient field
4240
this->matches_index_ = conf_v3.matches_;
43-
read_ok = true;
4441
} else {
4542
Warning(__func__, "Current version of AnalysisTree::Configuration (%d) "
4643
"is different from the version from file (%d) and no rule to read this version was implemented. "
4744
"Contact developers if dedicated Streamer implementation is needed for this version.",
4845
Configuration::Class()->GetClassVersion(),
4946
version_from_file);
50-
read_ok = false;
5147
}
5248

5349
} else {

core/Configuration.test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ TEST(Configuration, Basics) {
3131
EXPECT_EQ(config.GetNumberOfBranches(), 1);
3232
// EXPECT_EQ(config.GetLastId(), 0);
3333

34-
const auto& br1 = config.GetBranchConfig("RecTrack");
35-
// EXPECT_EQ(br1.GetId(), 0);
3634
}
3735

3836
TEST(Configuration, Match) {

infra/AnalysisEntry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool AnalysisEntry::ApplyCutOnBranches(std::vector<const Branch*>& br, std::vect
3232
std::vector<size_t> id_vec;
3333
bch_vec.reserve(br.size());
3434
id_vec.reserve(br.size());
35-
for (int i = 0; i < br.size(); i++) {
35+
for (int i = 0; i < static_cast<int>(br.size()); i++) {
3636
BranchChannel* bchptr = new BranchChannel(br.at(i), ch.at(i));
3737
if (cuts.at(i) != nullptr) {
3838
if (!cuts.at(i)->Apply(*bchptr)) {
@@ -71,7 +71,7 @@ double AnalysisEntry::FillVariable(const Variable& var, std::vector<const Branch
7171
std::vector<size_t> id_vec;
7272
bch_vec.reserve(br.size());
7373
id_vec.reserve(br.size());
74-
for (int i = 0; i < br.size(); i++) {
74+
for (int i = 0; i < static_cast<int>(br.size()); i++) {
7575
BranchChannel* bchptr = new BranchChannel(br.at(i), id.at(i));
7676
bch_vec.emplace_back(bchptr);
7777
id_vec.emplace_back(br.at(i)->GetId());

infra/Branch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ void Branch::CopyContentsRaw(Branch* other) {
169169
*ANALYSISTREE_UTILS_GET<EventHeader*>(data_) = *ANALYSISTREE_UTILS_GET<EventHeader*>(other->data_);
170170
break;
171171
}
172+
case DetType::kGeneric: {
173+
*ANALYSISTREE_UTILS_GET<GenericDetector*>(data_) = *ANALYSISTREE_UTILS_GET<GenericDetector*>(other->data_);
174+
break;
175+
}
176+
default:
177+
throw std::runtime_error("Branch::CopyContentsRaw(): unexpected branch type of 'this'");
172178
}
173179
}
174180

infra/GenericContainerFiller.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void GenericContainerFiller::Init() {
5555

5656
config_.AddBranchConfig(branchConfig);
5757

58-
for (int iV = 0; iV < branch_values_.size(); iV++) {
58+
for (int iV = 0; iV < static_cast<int>(branch_values_.size()); iV++) {
5959
SetAddressFICS(branch_map_.at(iV).name_, branch_map_.at(iV), branch_values_.at(iV));
6060
}
6161

@@ -95,8 +95,8 @@ void GenericContainerFiller::Finish() {
9595
void GenericContainerFiller::Run(int nEntries) {
9696
Init();
9797

98-
const size_t nTreeEntries = tree_in_->GetEntries();
99-
const size_t nRunEntries = (nEntries < 0 || nEntries > nTreeEntries) ? nTreeEntries : nEntries;
98+
const int nTreeEntries = tree_in_->GetEntries();
99+
const int nRunEntries = (nEntries < 0 || nEntries > nTreeEntries) ? nTreeEntries : nEntries;
100100

101101
int previousTriggerVar{-799};
102102
for (int iEntry = 0; iEntry < nRunEntries; iEntry++) {
@@ -108,8 +108,8 @@ void GenericContainerFiller::Run(int nEntries) {
108108
}
109109

110110
int GenericContainerFiller::DetermineFieldIdByName(const std::vector<IndexMap>& iMap, const std::string& name) {
111-
auto distance = std::distance(iMap.begin(), std::find_if(iMap.begin(), iMap.end(), [&name](const IndexMap& p) { return p.name_ == name; }));
112-
if (distance == iMap.size()) throw std::runtime_error("DetermineFieldIdByName(): name " + name + " is missing");
111+
const auto distance = static_cast<int>(std::distance(iMap.begin(), std::find_if(iMap.begin(), iMap.end(), [&name](const IndexMap& p) { return p.name_ == name; })));
112+
if (distance == static_cast<int>(iMap.size())) throw std::runtime_error("DetermineFieldIdByName(): name " + name + " is missing");
113113
return distance;
114114
}
115115

@@ -126,7 +126,7 @@ void GenericContainerFiller::SetAddressFICS(const std::string& branchName, const
126126
}
127127

128128
void GenericContainerFiller::SetFieldsFICS(const std::vector<IndexMap>& imap, Container& container, const std::vector<FICS>& ficc) {
129-
for (int iV = 0; iV < ficc.size(); iV++) {
129+
for (int iV = 0; iV < static_cast<int>(ficc.size()); iV++) {
130130
if (imap.at(iV).field_type_ == "TLeafF") container.SetField(ficc.at(iV).float_, imap.at(iV).index_);
131131
else if (imap.at(iV).field_type_ == "TLeafI")
132132
container.SetField(ficc.at(iV).int_, imap.at(iV).index_);
@@ -137,4 +137,4 @@ void GenericContainerFiller::SetFieldsFICS(const std::vector<IndexMap>& imap, Co
137137
else
138138
throw std::runtime_error("GenericContainerFiller::SetFieldsFICS(): unsupported filed type " + imap.at(iV).field_type_);
139139
}
140-
}
140+
}

infra/HelperFunctions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ inline std::vector<AnalysisTree::SimpleCut> CreateRangeCuts(const std::vector<fl
6161
if (precision < 0) precision = evaluateMaxDigisAfterComma(ranges);
6262

6363
std::vector<AnalysisTree::SimpleCut> sliceCuts;
64-
for (int iRange = 0; iRange < ranges.size() - 1; iRange++) {
64+
for (int iRange = 0; iRange < static_cast<int>(ranges.size()) - 1; iRange++) {
6565
const std::string cutName = cutNamePrefix + ToStringWithPrecision(ranges.at(iRange), precision) + "_" + ToStringWithPrecision(ranges.at(iRange + 1), precision);
6666
sliceCuts.emplace_back(AnalysisTree::RangeCut(branchFieldName, ranges.at(iRange), ranges.at(iRange + 1), cutName));
6767
}

infra/SimpleCut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ SimpleCut EqualsCut(const Variable& var, int value, const std::string& title) {
4343
return {var, value, title};
4444
}
4545

46-
SimpleCut OpenCut(const std::string& branchName, const std::string& title) {
47-
return SimpleCut({branchName + ".ones"}, [](const std::vector<double>& par) { return true; });
46+
SimpleCut OpenCut(const std::string& branchName) {
47+
return SimpleCut({branchName + ".ones"}, [](const std::vector<double>&) { return true; });
4848
}
4949

5050
SimpleCut::SimpleCut(const Variable& var, int value, std::string title) : title_(std::move(title)) {

infra/SimpleCut.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class SimpleCut {
8989
* is iterated and an iteration with no-cut is needed)
9090
* @param branchName name of the branch, which is present in other cuts
9191
*/
92-
friend SimpleCut OpenCut(const std::string& branchName, const std::string& title);
92+
friend SimpleCut OpenCut(const std::string& branchName);
9393

9494
/**
9595
* @brief Evaluates cut
@@ -139,7 +139,7 @@ SimpleCut RangeCut(const std::string& variable_name, double lo, double hi, const
139139
SimpleCut EqualsCut(const std::string& variable_name, int value, const std::string& title = "");
140140
SimpleCut RangeCut(const Variable& var, double lo, double hi, const std::string& title = "");
141141
SimpleCut EqualsCut(const Variable& var, int value, const std::string& title = "");
142-
SimpleCut OpenCut(const std::string& branchName, const std::string& title = "alwaysTrue");
142+
SimpleCut OpenCut(const std::string& branchName);
143143

144144
}// namespace AnalysisTree
145145
#endif//ANALYSISTREE_SIMPLECUT_H

infra/Variable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ double Variable::GetValue(std::vector<const BranchChannel*>& bch, std::vector<si
7979
vars_.clear();
8080
for (const auto& field : fields_) {
8181
bool success{false};
82-
for (int i = 0; i < bch.size(); i++) {
82+
for (int i = 0; i < static_cast<int>(bch.size()); i++) {
8383
if (field.GetBranchId() == id.at(i)) {
8484
vars_.emplace_back(bch.at(i)->Value(field));
8585
success = true;

0 commit comments

Comments
 (0)