@Override
	public void collectStats(SegmentEventRecoder recorder, StringBuilder builder) {
		if (AFS) {
			int[] freq = getFrequencySpectrum(recorder);
			lastAFS=freq;
			Util.arrayAdd(gloabalAFS, freq);
			if (!onlySummary) {
				builder.append("AFS: ");
				for (int i = 0; i < freq.length; i++) {
					builder.append(freq[i]).append(' ');
				}
				builder.append('\n');
			}
		}
		
		if (!jAFS)
			return;
		List<InfinteMutation> mutations = recorder.getMutationsUnsorted();
		clearPairArrays();
		int ndemes = demeMasks.length;
		int[] demeFreq = new int[ndemes];
		for (InfinteMutation mutation : mutations) {
			fillDemeFrequency(mutation.leafSet, demeFreq);
			// System.out.println(Arrays.toString(demeFreq));
			int pairCount = 0;
			for (int i = 0; i < ndemes; i++) {
				for (int j = i + 1; j < ndemes; j++) {
					pairwiseJAFS[pairCount][demeFreq[i]][demeFreq[j]]++;
					cumulantJAFS[pairCount++][demeFreq[i]][demeFreq[j]]++;
				}
			}
		}
		if (!onlySummary) {
			printJAFSmatrix(pairwiseJAFS, builder);
		}
	}