for haha in ['iba', 'ipnl']:
            if (haha + 'lyso' in line
                    or haha + 'bgo' in line) and haha + '-' in typ:
                print(haha, line, typ)
                ctsetsets.append(
                    auger.getctset(numprot,
                                   line[2:10],
                                   line[2:10],
                                   typ,
                                   addnoise=addnoise,
                                   precolli=precolli))
            if haha + 'zinv' in line and haha + '-' in typ:
                print(haha, line, typ)
                ctsetsets.append(
                    auger.getctset(numprot,
                                   line[2:10],
                                   line[2:10],
                                   typ,
                                   addnoise=addnoise,
                                   precolli=precolli))
    assert (len(ctsetsets) == 3)
    megaplot(ctsetsets, 'PMMA_phantom')
    print 'Mean detection yield in', typ, 'study over', sum(
        [ctset['totnprim'] for ctset in ctsetsets]), 'primaries in', sum([
            ctset['nreal'] for ctset in ctsetsets
        ]), 'realisations:', sum([ctset['detyieldmu'] for ctset in ctsetsets])

tableio.print2d(resultstable)
tableio.write(resultstable, 'resultstable.tsv')
	'ipnl-auger-tof-1.root',
	'iba-auger-tof-1.root',
	'ipnl-auger-notof-1.root',
	'iba-auger-notof-1.root',
	'ipnl-auger-tof-3.root',
	'iba-auger-tof-3.root',
	'ipnl-auger-notof-3.root',
	'iba-auger-notof-3.root']

# typs=['ipnl-auger-tof-1.root','iba-auger-tof-1.root','ipnl-auger-notof-3.root','iba-auger-notof-3.root']
dirs = subprocess.check_output(['find . -iname "*autogen*" | sort -k1.13'],shell=True).split('\n')[:-1]

numprots = [1e9,1e8,1e7,1e6]

for typ in typs:
    ctsetsets = []
    for line,numprot in zip(dirs,[item for item in numprots for i in range(len(typs)/4)]):
        for haha in ['iba','ipnl']:
            if haha+'lyso' in line and haha+'-' in typ:
                print (haha,line,typ)
                ctsetsets.append( auger.getctset(numprot,line[2:10],line[2:10],typ,addnoise=addnoise) )
            if haha+'zinv' in line and haha+'-' in typ:
                print (haha,line,typ)
                ctsetsets.append( auger.getctset(numprot,line[2:10],line[2:10],typ,addnoise=addnoise) )
    assert(len(ctsetsets)==4)
    megaplot(ctsetsets,'PMMA_phantom')
    print 'Mean detection yield in',typ,'study over',sum([ctset['totnprim'] for ctset in ctsetsets]),'primaries in',sum([ctset['nreal'] for ctset in ctsetsets]),'realisations:',sum([ctset['detyieldmu'] for ctset in ctsetsets])

tableio.print2d(resultstable)
tableio.write(resultstable,'resultstable.tsv')