    @Test public void testWeightHistogram() throws IOException {

        for (int q = 0; q < 300; q++) {
            int start = (int)Math.round(Math.random() * MAXVALUE);
            int end = start + (int)(Math.round(Math.random() * MAXVALUE) % (MAXVALUE - start));
            if (end < start) {
                throw new RuntimeException("end < start");
            }
            int binsize = 10 + (int)Math.round(Math.random() * 40);
            float[] histogram = hitsfile.weightHistogram(header.getFirstIndex(start),
                                                         header.getLastIndex(end),
                                                         start,end,binsize,0,null,null,false);
            float[] myhist = new float[(end - start) / binsize + 1];
            for (int i = 0; i < hits.size(); i++) {
                if (hits.get(i) >= start && hits.get(i) <= end) {
                    myhist[(hits.get(i) - start) / binsize] += weights.get(i);
                }
            }
            assertTrue(myhist.length == histogram.length);
            for (int i = 0; i < myhist.length; i++) {
                assertTrue(myhist[i] == histogram[i]);
            }
        }                
    }