Currently the following (admittedly trivial) loop in geant4 is not accepted: <constant name="num" value="1"/> <loop for="i" from="1" to="num" step="1"> <!-- stuff --> </loop> due to the following code in G4GDMLRead if (_from == _to) { G4Exception("G4GDMLRead::loopRead()", "InvalidRead", FatalException, "Empty loop!"); } This suggest that the loop is to be thought as the following C++ construct: for (int i = _from; i < _to; i += _step) { /* stuff */ } This conflicts with the actual interpretation: while (_var <= _to) { eval.SetVariable(var,_var); (this->*func)(element); _var += _step; loopCount++; } which indicates: for (int i = _from; i <= _to; i += _step) { /* stuff */ } This results in the following confusing behavior in examples/extended/persistency/gdml/G01, in particular loop.gdml: - With the default parameters (num = 4) you get 5 volumes. - Therefore, changing the parameter num = 0 you would expect 1 volume, but that fails due to the "Empty loop!" error. Suggestion: remove the Empty Loop error since any actual empty loop (from > to) would be caught by the subsequent Infinit Loop errors, e.g. if ((_from > _to) && (_step >= 0)) { G4Exception("G4GDMLRead::loopRead()", "InvalidRead", FatalException, "Infinite loop!"); }
Thanks for spotting that problem. The fix will be in the next release.