Skip to content

Commit 31f703f

Browse files
authored
Refactor conditionals for clarity in VDGeometryBuilder
1 parent 180fd48 commit 31f703f

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

Detectors/Upgrades/ALICE3/TRK/simulation/src/VDGeometryBuilder.cxx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,28 @@ inline bool isSolidToCut(const TGeoVolume* v)
5454
const char* nm = v->GetName();
5555
const char* med = v->GetMedium() ? v->GetMedium()->GetName() : "";
5656
// silicon sensors (barrel + disks)
57-
if (med && strcmp(med, "TRK_SILICON$") == 0)
57+
if (med && strcmp(med, "TRK_SILICON$") == 0) {
5858
return true;
59+
}
5960
// walls, sidewalls, cold-plate, service rings (names from your builders)
60-
if (TString(nm).BeginsWith("VD_InnerWallArc"))
61+
if (TString(nm).BeginsWith("VD_InnerWallArc")) {
6162
return true;
62-
if (TString(nm).BeginsWith("VD_OuterWallArc"))
63+
}
64+
if (TString(nm).BeginsWith("VD_OuterWallArc")) {
6365
return true;
64-
if (TString(nm).BeginsWith("VD_SideWall"))
66+
}
67+
if (TString(nm).BeginsWith("VD_SideWall")) {
6568
return true;
66-
if (TString(nm).Contains("_Coldplate"))
69+
}
70+
if (TString(nm).Contains("_Coldplate")) {
6771
return true;
68-
if (TString(nm).BeginsWith("IRIS_Service_Neg"))
72+
}
73+
if (TString(nm).BeginsWith("IRIS_Service_Neg")) {
6974
return true;
70-
if (TString(nm).BeginsWith("IRIS_Service_Pos_InVac"))
75+
}
76+
if (TString(nm).BeginsWith("IRIS_Service_Pos_InVac")) {
7177
return true;
78+
}
7279
return false;
7380
}
7481

@@ -86,8 +93,9 @@ inline const char* ensureShapeName(TGeoVolume* v)
8693
while (shapes && shapes->FindObject(cand))
8794
cand = Form("%s_%d", wanted.Data(), ++k);
8895
sh->SetName(cand);
89-
if (shapes && !shapes->FindObject(cand))
96+
if (shapes && !shapes->FindObject(cand)) {
9097
shapes->Add(sh);
98+
}
9199
}
92100
return sh->GetName();
93101
}
@@ -102,23 +110,26 @@ inline void appendLocalTerm(const char* shapeName, const TGeoHMatrix& H)
102110
auto* ct = new TGeoCombiTrans(H);
103111
ct->SetName(Form("IRIS_LOC_TR_%d", gLocalTrIdx++));
104112
ct->RegisterYourself();
105-
if (!gPetalSolidsFormula.IsNull())
113+
if (!gPetalSolidsFormula.IsNull()) {
106114
gPetalSolidsFormula += "+";
115+
}
107116
gPetalSolidsFormula += TString::Format("%s:%s", shapeName, ct->GetName());
108117
}
109118

110119
// DFS: compose LOCAL transforms only (identity prefix), to capture the petal contents
111120
void traversePetalLocal(TGeoVolume* vol, const TGeoHMatrix& prefix)
112121
{
113122
auto* nodes = vol->GetNodes();
114-
if (!nodes)
123+
if (!nodes) {
115124
return;
125+
}
116126
for (int i = 0; i < nodes->GetEntriesFast(); ++i) {
117127
auto* node = (TGeoNode*)nodes->At(i);
118128
auto* childV = node->GetVolume();
119129
TGeoHMatrix H(prefix);
120-
if (auto* m = node->GetMatrix())
130+
if (auto* m = node->GetMatrix()) {
121131
H.Multiply(m);
132+
}
122133

123134
if (isSolidToCut(childV)) {
124135
const char* shapeName = ensureShapeName(childV);
@@ -132,8 +143,9 @@ void traversePetalLocal(TGeoVolume* vol, const TGeoHMatrix& prefix)
132143
inline void buildPetalSolidsComposite(TGeoVolume* petalAsm)
133144
{
134145
// If it already exists, skip
135-
if (gGeoManager && gGeoManager->GetListOfShapes() && gGeoManager->GetListOfShapes()->FindObject("IRIS_PETAL_SOLIDSsh"))
146+
if (gGeoManager && gGeoManager->GetListOfShapes() && gGeoManager->GetListOfShapes()->FindObject("IRIS_PETAL_SOLIDSsh")) {
136147
return;
148+
}
137149

138150
gPetalSolidsFormula.Clear();
139151
gLocalTrIdx = 0;
@@ -162,8 +174,9 @@ inline void buildIrisCutoutFromPetalSolid(int nPetals)
162174
auto* RT = new TGeoCombiTrans(0, 0, 0, R);
163175
RT->SetName(Form("IRIS_PETAL_ROT_%d", p));
164176
RT->RegisterYourself();
165-
if (p)
177+
if (p) {
166178
cutFormula += "+";
179+
}
167180
cutFormula += Form("IRIS_PETAL_SOLIDSsh:%s", RT->GetName());
168181
}
169182
LOGP(info, "IRIS_CUTOUTsh formula: {}", cutFormula.Data());
@@ -257,8 +270,9 @@ inline double degFromArc(double arc, double radius)
257270
*/
258271
inline double phiSpanFromGap(int nPetals, double gap, double radius)
259272
{
260-
if (nPetals <= 0 || radius <= 0.f)
273+
if (nPetals <= 0 || radius <= 0.f) {
261274
return 0.f;
275+
}
262276
const double petalPhiDeg = 360.f / nPetals;
263277
const double phi = petalPhiDeg - degFromArc(gap, radius);
264278
return phi > 0.f ? phi : 0.f;

0 commit comments

Comments
 (0)