private void calcGenomehs() {
        genomenr = new int[popdata.chromCount()][][];
        genomehs = new ArrayList<ArrayList<ArrayList<ArrayList<Integer>>>>(); //for each genome nr:
            //which haplostructs in initorder have this genome nr (for both sides) 
        possiblePairCount = new int[popdata.chromCount()][];
        for (int chr=0; chr<popdata.chromCount(); chr++) {
            genomehs.add(new ArrayList<ArrayList<ArrayList<Integer>>>());
            //TetraploidChromosome chrom = (TetraploidChromosome)popdata.getChrom(chr);
            //if (chrom.getPrefPairingProb() > 0.0) {
            genomenr[chr] = new int[2][popdata.ploidy];
            possiblePairCount[chr] = new int[] {0,0}; //the number of possible preferential pairs
                //(for both sides)
            for (int side=0; side<2; side++) {
                genomehs.get(chr).add( new ArrayList<ArrayList<Integer>>());
                for (int g=0; g<popdata.ploidy/2; g++) {
                    genomehs.get(chr).get(side).add(new ArrayList<Integer>());
                }
                for (int h=0; h<popdata.ploidy; h++) {
                    //first get the genome number at the haplostruct side:
                    genomenr[chr][side][h] = (side==0 ?
                            haplostruct[chr][h].getFounderAtHead() :
                            haplostruct[chr][h].getFounderAtTail())
                            % (popdata.ploidy/2);
                    //and list all the haplostruct sides in genomehs:
                    genomehs.get(chr).get(side).get(genomenr[chr][side][h]).add(h);
                }
                //count the number of possible prefpairs at this side:
                for (int g=0; g<popdata.ploidy/2; g++) {
                    possiblePairCount[chr][side] += 
                            genomehs.get(chr).get(side).get(g).size()/2;
                }
            } //for side 
        } //for chr    
    } //calcGenomehs