Skip to content

Commit 9fa39d4

Browse files
ggalgoczigithub-actions[bot]plexoos
authored
Safeguard for Opticks binary tree size (#141)
Stop Opticks geometry read-in if binary tree size blows up. Warn user and suggest solution. Solves #77 Test: ./build/src/simg4ox -g dune_forward_geometry_2025_april_replaced_elliptical_tubes.gdml -m esi-g4ox/run.mac Exits with error as expected: ```Too many nodes in binary tree (more than a 100 000) built by Opticks. Likely a nested subtraction/union solid that Opticks turns into a full binary tree. Check your geometry as described in: BNLNPPS/esi-g4ox#127 simg4ox: /esi/eic-opticks/CSG/CSGImport.cc:312: CSGPrim* CSGImport::importPrim(int, const snode&): Assertion `bn < 100000' failed. ``` Fixed DUNE geometry works fine, no exit: ./build/src/simg4ox -g duneforwarddetector3.gdml -m esi-g4ox/run.mac --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Dmitri Smirnov <dmixsmi@gmail.com>
1 parent 34f563c commit 9fa39d4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

CSG/CSGImport.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,17 @@ CSGPrim* CSGImport::importPrim(int primIdx, const snode& node )
309309
sn::GetLVNodesComplete(nds, lvid); // many nullptr in unbalanced deep complete binary trees
310310
int bn = nds.size(); // binary nodes
311311

312-
// 2. count total subs for any listnodes of this lvid
312+
// Check if binary tree blows up and warn user
313+
LOG_IF(warning, bn > 100000)
314+
<< "Too many nodes in binary tree (more than a 100 000) built by Opticks. Likely a nested "
315+
"subtraction/union solid that Opticks turns into a full binary tree. Check your geometry as "
316+
"described in: https://github.com/BNLNPPS/esi-g4ox/issues/127";
313317

314-
std::vector<const sn*> lns ;
315-
sn::GetLVListnodes( lns, lvid );
316-
int num_sub_total = sn::GetChildTotal( lns );
318+
// 2. count total subs for any listnodes of this lvid
317319

320+
std::vector<const sn *> lns;
321+
sn::GetLVListnodes(lns, lvid);
322+
int num_sub_total = sn::GetChildTotal(lns);
318323
int ln = lns.size();
319324
bool ln_expect = ln == 0 || ln == 1 ;
320325

0 commit comments

Comments
 (0)