Esempio n. 1
0
def effective_area(frame, model, generator):
    mctree = frame["I3MCTree"]
    primary = mctree.primaries[0]
    muon = mctree.get_daughters(primary)[0]
    bundle = MuonGun.BundleConfiguration([MuonGun.BundleEntry(0, muon.energy)])
    area = 1 / generator.generated_events(primary, bundle)
    frame["MCMuon"] = muon
    frame["MuonEffectiveArea"] = dataclasses.I3Double(area)
    weighter = MuonGun.WeightCalculator(model, generator)
    weight = weighter(primary, bundle)
    frame["MuonWeight"] = dataclasses.I3Double(weight)
    return True
Esempio n. 2
0
e = numpy.logspace(1, 7, 101)

target = MuonGun.load_model('Hoerandel5_atmod12_SIBYLL')
# target = MuonGun.load_model('GaisserH4a_atmod12_SIBYLL')

generators = [
    ('200k $E^{-2}$ 5-component CORSIKA', 2e5 * hard),
    ('300k $E^{-2.6}$ 5-component CORSIKA', (300e3) * soft),
    ('200k unweighted CORSIKA', 2e5 * unweighted),
    ('1k MuonGun (100k muons each)', 1e3 * gun),
    ('total', 2e5 * hard + 300e3 * soft + 2e5 * unweighted + 1e3 * gun),
]

fig = pylab.figure(figsize=(6, 4))
fig.subplots_adjust(bottom=0.15)

annum = 365 * 24 * 3600
for label, generator in generators:
    weighter = MuonGun.WeightCalculator(target, generator)
    pylab.plot(e,
               1. / (get_weight(weighter, e, scale=True) * annum),
               label=label)

pylab.loglog()
pylab.legend(loc='lower right', prop=dict(size='x-small'))
pylab.ylabel('Single-muon livetime [years]')
pylab.xlabel('Muon energy at sampling surface [GeV]')
pylab.grid()

pylab.savefig(args.outfile)
Esempio n. 3
0
book_weights(infiles, outfile)

try:
    import tables, pylab, numpy

    hdf = tables.openFile(outfile)

    # We can get pre-calculated weights calcuated by the icetray module
    muon_energy = hdf.root.Muon.cols.energy[:]
    pre_weights = hdf.root.MuonWeight.cols.value[:]

    # or make a freestanding WeightCalculator with a different flux model
    model = MuonGun.load_model('GaisserH4a_atmod12_SIBYLL')
    generator = harvest_generators(infiles)
    weighter = MuonGun.WeightCalculator(model, generator)

    # and use the bundle axis and its radius/energy distribution to calculate a weight
    axis = hdf.root.MCPrimary.read()
    bundle = hdf.root.BundleParameters.read()
    post_weights = weighter(axis['x'], axis['y'], axis['z'], axis['zenith'],
                            axis['azimuth'], bundle['multiplicity'],
                            bundle['energy'], bundle['radius'])

    pylab.hist(muon_energy,
               bins=numpy.logspace(4, 7, 101),
               log=True,
               histtype='bar',
               label='unweighted (counts)')
    pylab.hist(muon_energy,
               weights=post_weights,