@@ -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
229235LGADHitClustering::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
234241int 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