Skip to content

Commit fbc4fe6

Browse files
committed
refactor(Base): FairModule::ProcessNodes further
* [CPPCG::ES.5 Keep scopes small](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es5-keep-scopes-small) * [CPPCG::ES.11 Use `auto` to avoid redundant repetition of type names](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-auto) * Rename `fNodes` to `parNodes` - the `f`-prefix is reserved for member variables * Default to prefix increment operator for readibility, especially if return value is ignored * `FairGeoNode` is a `FairGeoVolume` - no `dynamic_cast` needed * Explicitely `std::ignore` return values
1 parent 98aa8ba commit fbc4fe6

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

fairroot/base/sim/FairModule.cxx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <TKey.h> // for TKey
3737
#include <TObjArray.h> // for TObjArray
3838
#include <TObject.h> // for TObject
39+
#include <TSeqCollection.h> // for TSeqCollection
3940
#include <TSystem.h> // for TSystem, gSystem
4041
#include <fairlogger/Logger.h>
4142

@@ -47,6 +48,7 @@
4748
#include <cstring> // for strcmp, strlen
4849
#include <map>
4950
#include <memory>
51+
#include <tuple> // for std::ignore
5052

5153
thread_local std::vector<FairVolume*> FairModule::fAllSensitiveVolumes;
5254

@@ -211,19 +213,19 @@ void FairModule::ProcessNodes(TList* nodes)
211213
vList = new FairVolumeList();
212214
}
213215

214-
FairGeoNode* MotherNode = nullptr;
215-
FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
216-
FairGeoParSet* par = static_cast<FairGeoParSet*>(rtdb->getContainer("FairGeoParSet"));
217-
TObjArray* fNodes = par->GetGeoNodes();
216+
auto rtdb = FairRun::Instance()->GetRuntimeDb();
217+
auto par = static_cast<FairGeoParSet*>(rtdb->getContainer("FairGeoParSet"));
218+
TSeqCollection* parNodes = par->GetGeoNodes();
218219
for (auto node : TRangeDynCast<FairGeoNode>(nodes)) {
219220
if (!node) {
220221
continue;
221222
}
222-
node->calcLabTransform();
223-
MotherNode = node->getMotherNode();
223+
std::ignore = node->calcLabTransform();
224+
224225
auto nodeTruncName = node->getTruncName();
225226
auto volume = std::make_unique<FairVolume>(nodeTruncName, fNbOfVolumes++);
226227
volume->setRealName(node->GetName());
228+
227229
auto addedVol = vList->addVolume(std::move(volume));
228230
if (!addedVol) {
229231
LOG(warn) << "Skipping further processing of FairGeoNode " << nodeTruncName
@@ -233,19 +235,18 @@ void FairModule::ProcessNodes(TList* nodes)
233235
addedVol->setGeoNode(node);
234236
addedVol->setCopyNo(node->getCopyNo());
235237

236-
if (MotherNode != 0) {
238+
auto motherNode = node->getMotherNode();
239+
if (motherNode) {
237240
addedVol->setMotherId(node->getMCid());
238-
addedVol->setMotherCopyNo(MotherNode->getCopyNo());
241+
addedVol->setMotherCopyNo(motherNode->getCopyNo());
239242
}
240-
FairGeoVolume* aVol = nullptr;
241243

242244
if (node->isSensitive() && fActive) {
243245
addedVol->setModId(fModId);
244246
addedVol->SetModule(this);
245247
fAllSensitiveVolumes.push_back(addedVol);
246-
aVol = dynamic_cast<FairGeoVolume*>(node);
247-
fNodes->AddLast(aVol);
248-
fNbOfSensitiveVol++;
248+
++fNbOfSensitiveVol;
249+
parNodes->AddLast(node);
249250
}
250251
}
251252
}

0 commit comments

Comments
 (0)