Skip to content

Commit 3adc7b3

Browse files
authored
clang-tidy: readability-braces-around-statements (#2117)
### Briefly, what does this PR introduce? This PR applies clang-tidy readability-braces-around-statements check fixes from main. ### What kind of change does this PR introduce? - [x] Bug fix (issue: code base should satisfy PR clang-tidy requirements) - [ ] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No.
1 parent 690faa4 commit 3adc7b3

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

src/algorithms/calorimetry/CalorimeterHitDigi.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,10 @@ void CalorimeterHitDigi::process(const CalorimeterHitDigi::Input& input,
248248
0LL);
249249
}
250250

251-
if (edep > 1.e-3)
251+
if (edep > 1.e-3) {
252252
trace("E sim {} \t adc: {} \t time: {}\t maxtime: {} \t tdc: {} \t corrMeanScale: {}", edep,
253253
adc, time, m_cfg.capTime, tdc, corrMeanScale_value);
254+
}
254255

255256
rawhit.setCellID(leading_hit.getCellID());
256257
rawhit.setAmplitude(adc > m_cfg.capADC ? m_cfg.capADC : adc);

src/algorithms/calorimetry/ImagingClusterReco.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ ImagingClusterReco::get_primary(const edm4hep::CaloHitContribution& contrib) con
319319
// can be improved!!
320320
edm4hep::MCParticle primary = contributor;
321321
while (primary.parents_size() > 0) {
322-
if (primary.getGeneratorStatus() != 0)
322+
if (primary.getGeneratorStatus() != 0) {
323323
break;
324+
}
324325
primary = primary.getParents(0);
325326
}
326327
return primary;

src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ edm4hep::MCParticle lookup_primary(const edm4hep::CaloHitContribution& contrib)
7777

7878
edm4hep::MCParticle primary = contributor;
7979
while (primary.parents_size() > 0) {
80-
if (primary.getGeneratorStatus() != 0)
80+
if (primary.getGeneratorStatus() != 0) {
8181
break;
82+
}
8283
primary = primary.getParents(0);
8384
}
8485
return primary;

src/algorithms/digi/SiliconPulseDiscretization.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ void SiliconPulseDiscretization::process(const SiliconPulseDiscretization::Input
9393
outPulse.setTime(startTime);
9494

9595
// stop at the next cycle
96+
// NOLINTNEXTLINE(clang-analyzer-security.FloatLoopCounter, security.FloatLoopCounter)
9697
for (double currTime = startTime; currTime < startTime + m_cfg.EICROC_period;
97-
currTime += m_cfg.local_period)
98+
currTime += m_cfg.local_period) {
9899
outPulse.addToAdcCounts(this->_interpolateOrZero(graph, currTime, tMin, tMax));
100+
}
99101
}
100102
}
101103
} // SiliconPulseDiscretization:process

src/algorithms/tracking/LGADHitClustering.cc

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ void LGADHitClustering::_calcCluster(const Output& output,
8787
}
8888
// weigh all hits by ADC value
8989
auto pos = m_seg->position(hit.getCellID());
90-
if (hit.getEdep() < 0)
90+
if (hit.getEdep() < 0) {
9191
error("Edep for hit at cellID{} is negative. Please check the accuracy of your energy "
9292
"calibration. ",
9393
hit.getCellID());
94+
}
9495
const auto Edep = hit.getEdep();
9596
ave_x += Edep * pos.x();
9697
ave_y += Edep * pos.y();
@@ -129,8 +130,9 @@ void LGADHitClustering::_calcCluster(const Output& output,
129130
cov(1, 1) = sigma2_y;
130131
cov(0, 1) = cov(1, 0) = 0.0;
131132

132-
for (const auto& w : weights)
133+
for (const auto& w : weights) {
133134
cluster.addToWeights(w);
135+
}
134136

135137
edm4eic::Cov3f covariance;
136138
edm4hep::Vector2f locPos{static_cast<float>(ave_x / mm), static_cast<float>(ave_y / mm)};
@@ -139,8 +141,9 @@ void LGADHitClustering::_calcCluster(const Output& output,
139141
auto volID = context->identifier;
140142
const auto& surfaceMap = m_acts_context->surfaceMap();
141143
const auto is = surfaceMap.find(volID);
142-
if (is == surfaceMap.end())
144+
if (is == surfaceMap.end()) {
143145
error("vol_id ({}) not found in m_surfaces.", volID);
146+
}
144147

145148
const Acts::Surface* surface = is->second;
146149

@@ -178,22 +181,25 @@ void LGADHitClustering::process(const LGADHitClustering::Input& input,
178181
for (const auto& neighborCandidates : cellNeighbors) {
179182
auto it = hitIDsByCells.find(neighborCandidates);
180183
if (it != hitIDsByCells.end()) {
181-
for (const auto& hitID1 : hitIDs)
184+
for (const auto& hitID1 : hitIDs) {
182185
for (const auto& hitID2 : it->second) {
183186
const auto& hit1 = calibrated_hits->at(hitID1);
184187
const auto& hit2 = calibrated_hits->at(hitID2);
185188
// only consider hits with time difference < deltaT as the same cluster
186-
if (std::fabs(hit1.getTime() - hit2.getTime()) < m_cfg.deltaT)
189+
if (std::fabs(hit1.getTime() - hit2.getTime()) < m_cfg.deltaT) {
187190
uf.merge(hitID1, hitID2);
191+
}
188192
}
193+
}
189194
}
190195
}
191196
}
192197

193198
// group hits by cluster parent index according to union find algorithm
194199
std::unordered_map<int, std::vector<edm4eic::TrackerHit>> clusters;
195-
for (size_t hitID = 0; hitID < calibrated_hits->size(); ++hitID)
200+
for (size_t hitID = 0; hitID < calibrated_hits->size(); ++hitID) {
196201
clusters[uf.find(hitID)].push_back(calibrated_hits->at(hitID));
202+
}
197203

198204
// calculated weighted averages
199205
for (auto& [_, cluster] : clusters) {
@@ -227,13 +233,15 @@ LGADHitClustering::getLocalSegmentation(const dd4hep::rec::CellID& cellID) const
227233
}
228234

229235
LGADHitClustering::UnionFind::UnionFind(int n) : mParent(n, 0), mRank(n, 0) {
230-
for (int i = 0; i < n; ++i)
236+
for (int i = 0; i < n; ++i) {
231237
mParent[i] = i;
238+
}
232239
}
233240

234241
int LGADHitClustering::UnionFind::find(int id) {
235-
if (mParent[id] == id)
242+
if (mParent[id] == id) {
236243
return id;
244+
}
237245
return mParent[id] = find(mParent[id]); // path compression
238246
}
239247

@@ -242,11 +250,11 @@ void LGADHitClustering::UnionFind::merge(int id1, int id2) {
242250
auto root2 = find(id2);
243251

244252
if (root1 != root2) {
245-
if (mRank[root1] > mRank[root2])
253+
if (mRank[root1] > mRank[root2]) {
246254
mParent[root2] = root1;
247-
else if (mRank[root1] < mRank[root2])
255+
} else if (mRank[root1] < mRank[root2]) {
248256
mParent[root1] = root2;
249-
else {
257+
} else {
250258
mParent[root1] = root2;
251259
mRank[root2]++;
252260
}

0 commit comments

Comments
 (0)