From 31f703fbfb435a44b46104b032889dda8c055856 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Thu, 30 Oct 2025 08:56:30 +0100 Subject: [PATCH 1/2] Refactor conditionals for clarity in VDGeometryBuilder --- .../TRK/simulation/src/VDGeometryBuilder.cxx | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx b/Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx index 54567a50fa4cf..660b4e7c28931 100644 --- a/Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx +++ b/Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx @@ -54,21 +54,28 @@ inline bool isSolidToCut(const TGeoVolume* v) const char* nm = v->GetName(); const char* med = v->GetMedium() ? v->GetMedium()->GetName() : ""; // silicon sensors (barrel + disks) - if (med && strcmp(med, "TRK_SILICON$") == 0) + if (med && strcmp(med, "TRK_SILICON$") == 0) { return true; + } // walls, sidewalls, cold-plate, service rings (names from your builders) - if (TString(nm).BeginsWith("VD_InnerWallArc")) + if (TString(nm).BeginsWith("VD_InnerWallArc")) { return true; - if (TString(nm).BeginsWith("VD_OuterWallArc")) + } + if (TString(nm).BeginsWith("VD_OuterWallArc")) { return true; - if (TString(nm).BeginsWith("VD_SideWall")) + } + if (TString(nm).BeginsWith("VD_SideWall")) { return true; - if (TString(nm).Contains("_Coldplate")) + } + if (TString(nm).Contains("_Coldplate")) { return true; - if (TString(nm).BeginsWith("IRIS_Service_Neg")) + } + if (TString(nm).BeginsWith("IRIS_Service_Neg")) { return true; - if (TString(nm).BeginsWith("IRIS_Service_Pos_InVac")) + } + if (TString(nm).BeginsWith("IRIS_Service_Pos_InVac")) { return true; + } return false; } @@ -86,8 +93,9 @@ inline const char* ensureShapeName(TGeoVolume* v) while (shapes && shapes->FindObject(cand)) cand = Form("%s_%d", wanted.Data(), ++k); sh->SetName(cand); - if (shapes && !shapes->FindObject(cand)) + if (shapes && !shapes->FindObject(cand)) { shapes->Add(sh); + } } return sh->GetName(); } @@ -102,8 +110,9 @@ inline void appendLocalTerm(const char* shapeName, const TGeoHMatrix& H) auto* ct = new TGeoCombiTrans(H); ct->SetName(Form("IRIS_LOC_TR_%d", gLocalTrIdx++)); ct->RegisterYourself(); - if (!gPetalSolidsFormula.IsNull()) + if (!gPetalSolidsFormula.IsNull()) { gPetalSolidsFormula += "+"; + } gPetalSolidsFormula += TString::Format("%s:%s", shapeName, ct->GetName()); } @@ -111,14 +120,16 @@ inline void appendLocalTerm(const char* shapeName, const TGeoHMatrix& H) void traversePetalLocal(TGeoVolume* vol, const TGeoHMatrix& prefix) { auto* nodes = vol->GetNodes(); - if (!nodes) + if (!nodes) { return; + } for (int i = 0; i < nodes->GetEntriesFast(); ++i) { auto* node = (TGeoNode*)nodes->At(i); auto* childV = node->GetVolume(); TGeoHMatrix H(prefix); - if (auto* m = node->GetMatrix()) + if (auto* m = node->GetMatrix()) { H.Multiply(m); + } if (isSolidToCut(childV)) { const char* shapeName = ensureShapeName(childV); @@ -132,8 +143,9 @@ void traversePetalLocal(TGeoVolume* vol, const TGeoHMatrix& prefix) inline void buildPetalSolidsComposite(TGeoVolume* petalAsm) { // If it already exists, skip - if (gGeoManager && gGeoManager->GetListOfShapes() && gGeoManager->GetListOfShapes()->FindObject("IRIS_PETAL_SOLIDSsh")) + if (gGeoManager && gGeoManager->GetListOfShapes() && gGeoManager->GetListOfShapes()->FindObject("IRIS_PETAL_SOLIDSsh")) { return; + } gPetalSolidsFormula.Clear(); gLocalTrIdx = 0; @@ -162,8 +174,9 @@ inline void buildIrisCutoutFromPetalSolid(int nPetals) auto* RT = new TGeoCombiTrans(0, 0, 0, R); RT->SetName(Form("IRIS_PETAL_ROT_%d", p)); RT->RegisterYourself(); - if (p) + if (p) { cutFormula += "+"; + } cutFormula += Form("IRIS_PETAL_SOLIDSsh:%s", RT->GetName()); } LOGP(info, "IRIS_CUTOUTsh formula: {}", cutFormula.Data()); @@ -257,8 +270,9 @@ inline double degFromArc(double arc, double radius) */ inline double phiSpanFromGap(int nPetals, double gap, double radius) { - if (nPetals <= 0 || radius <= 0.f) + if (nPetals <= 0 || radius <= 0.f) { return 0.f; + } const double petalPhiDeg = 360.f / nPetals; const double phi = petalPhiDeg - degFromArc(gap, radius); return phi > 0.f ? phi : 0.f; From 578dd924902b1049825b8dd07cc6a980119927db Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Thu, 30 Oct 2025 08:58:43 +0100 Subject: [PATCH 2/2] Fix while loop syntax for shape name generation --- .../Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx b/Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx index 660b4e7c28931..5df875713262c 100644 --- a/Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx +++ b/Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx @@ -90,8 +90,9 @@ inline const char* ensureShapeName(TGeoVolume* v) int k = 0; TString cand = wanted; auto* shapes = gGeoManager ? gGeoManager->GetListOfShapes() : nullptr; - while (shapes && shapes->FindObject(cand)) + while (shapes && shapes->FindObject(cand)) { cand = Form("%s_%d", wanted.Data(), ++k); + } sh->SetName(cand); if (shapes && !shapes->FindObject(cand)) { shapes->Add(sh);