lcsim/src/org/lcsim/util/loop
diff -u -r1.4 -r1.5
--- StdhepConverter.java 3 Aug 2006 22:25:02 -0000 1.4
+++ StdhepConverter.java 8 Dec 2006 23:58:21 -0000 1.5
@@ -21,12 +21,13 @@
* A class that converts MCEvent<-->StdhepEvent.
* This version uses the Ron Cassell algorithm for deciding on parent/child relationships.
* @author Tony Johnson ([log in to unmask])
- * @version $Id: StdhepConverter.java,v 1.4 2006/08/03 22:25:02 tonyj Exp $
+ * @version $Id: StdhepConverter.java,v 1.5 2006/12/08 23:58:21 tonyj Exp $
*/
class StdhepConverter
{
private ParticlePropertyProvider ppp;
private GeneratorFactory factory;
+ private boolean haveWarned;
StdhepConverter()
{
@@ -101,33 +102,37 @@
private int fillIndexVec(int[] vec, int idx1, int idx2)
{
int l = 0;
- if ( idx1 >= 0 && idx2 >= 0 )
+ try
{
- if ( idx1 < idx2 )
+ if ( idx1 >= 0 && idx2 >= 0 )
{
- for ( int i = idx1; i < (idx2 + 1); i++ )
+ if ( idx1 < idx2 )
{
- vec[l++] = i;
+ for ( int i = idx1; i < (idx2 + 1); i++ )
+ {
+ vec[l++] = i;
+ }
+ }
+ else if ( idx1 > idx2 )
+ {
+ vec[l++] = idx1;
+ vec[l++] = idx2;
+ }
+ // indices are equal
+ else
+ {
+ vec[l++] = idx1;
}
}
- else if ( idx1 > idx2 )
- {
- vec[l++] = idx1;
- vec[l++] = idx2;
- }
- // indices are equal
- else
+ else if ( idx1 >= 0 )
{
vec[l++] = idx1;
}
}
- else if ( idx1 >= 0 )
- {
- vec[l++] = idx1;
- }
- else if ( idx2 >= 0 )
+ catch (ArrayIndexOutOfBoundsException x)
{
- vec[l++] = idx2;
+ if (!haveWarned) System.err.println("Warning: Array index out of bounds exception caused by corrupt stdhep file ignored");
+ haveWarned = true;
}
return l;
}