def __init__(self, context): super(self, DFastFiller).__init__(context) from icecube.MuonGun import Cylinder self.cyl = Cylinder(1600, 800) mindepth = self.GetParameter("MinDepth") maxdepth = self.GetParameter("MaxDepth") steps = self.GetParameter("DepthSteps") self.depthbins = numpy.linspace(mindepth, maxdepth, steps)
class DFastFiller(FastFiller): def __init__(self, context): super(self, DFastFiller).__init__(context) from icecube.MuonGun import Cylinder self.cyl = Cylinder(1600, 800) mindepth = self.GetParameter("MinDepth") maxdepth = self.GetParameter("MaxDepth") steps = self.GetParameter("DepthSteps") self.depthbins = numpy.linspace(mindepth, maxdepth, steps) def DAQ(self, frame): from icecube.dataclasses import I3Constants primary = frame['MCPrimary'] impact = self.cyl.intersection(primary.pos, primary.dir) d0 = I3Constants.SurfaceElev - I3Constants.OriginElev - (primary.pos.z + impact.first*primary.dir.z) di = numpy.floor(len(self.depthbins)*(d0 - mindepth)/(maxdepth-mindepth)) energy = primary.energy zenith = primary.dir.zenith weight = float(self.weighter(energy, zenith)) # weight = 1. self.binner.consume(frame['Tracks'], energy, zenith, weight) self.nevents += 1
def Configure(self): from icecube.MuonGun import MuonPropagator, Crust, Sphere, Cylinder self.crust = Crust(MuonPropagator("air", ecut=-1, vcut=5e-2, rho=0.673)) self.crust.add_layer(Sphere(1948, 6374134), MuonPropagator("ice", ecut=-1, vcut=5e-2, rho=0.832)) self.crust.add_layer(Sphere(1748, 6373934), MuonPropagator("ice", ecut=-1, vcut=5e-2, rho=1.005)) self.crust.add_layer(Cylinder(1600, 800), MuonPropagator("ice", ecut=-1, vcut=5e-2, rho=1.005))
def find_intersection(frame): from icecube.MuonGun import Cylinder from icecube.dataclasses import I3Constants, I3VectorDouble primary = frame['I3MCTree'].primaries[0] impact = Cylinder(1600, 800).intersection(primary.pos, primary.dir) d0 = I3Constants.SurfaceElev - I3Constants.OriginElev - (primary.pos.z + impact.first*primary.dir.z) frame['Depths'] = I3VectorDouble([d0])
def main(): #arguement parser parser = argparse.ArgumentParser( description='Generates muons in IceCube with varying multiplicity') parser.add_argument('--nseed', default=1, type=int, help='seed for randomization') #muongun args parser.add_argument('--model', default='GaisserH4a_atmod12_SIBYLL', type=str) parser.add_argument('--multiplicity', default=1000, type=int, help='Maximum muon bundle multiplcity') parser.add_argument('--emin', default=1e1, type=float, help='Muon min energy (GeV)') parser.add_argument('--emax', default=1e6, type=float, help='Muon max energy (GeV)') parser.add_argument('--nevents', default=100, type=int, help='Number of events') parser.add_argument('--out', default='muongun.i3.gz', help='Output file') parser.add_argument('--runnum', default=1, type=int, help='Run number for this sim') #detector args parser.add_argument( '--gcd', default=os.path.expandvars( '$I3_TESTDATA/sim/GeoCalibDetectorStatus_IC86.55697_corrected_V2.i3.gz' ), type=str, help='gcd file') parser.add_argument( '--no-hybrid', action="store_false", default=False, dest='hybrid', help='do not perform a hybrid simulation (i.e. use clsim only)') parser.add_argument('--use-gpu', action='store_true', default=False, help='simulate using GPUs instead of CPU cores') args = parser.parse_args() #setup muongun parameters gcdFile = args.gcd model = load_model(args.model) model.flux.max_multiplicity = args.multiplicity surface = Cylinder(1600 * I3Units.m, 800 * I3Units.m, dataclasses.I3Position(0, 0, 0)) surface_det = MuonGun.ExtrudedPolygon.from_file(gcdFile) spectrum = OffsetPowerLaw(2, 0 * I3Units.TeV, args.emin, args.emax) #spectrum = OffsetPowerLaw(2.65, 0*I3Units.TeV, args.emin, args.emax) generator = StaticSurfaceInjector(surface, model.flux, spectrum, model.radius) #setup reconstruction parameters icetray.load('VHESelfVeto') pulses = 'InIcePulses' HLCpulses = 'HLCInIcePulses' #setup I3Tray tray = I3Tray() tray.context['I3RandomService'] = phys_services.I3GSLRandomService( seed=args.nseed) #generate events tray.AddSegment(GenerateBundles, 'MuonGenerator', Generator=generator, NEvents=args.nevents, GCDFile=gcdFile) #propagate particles tray.Add(segments.PropagateMuons, 'PropagateMuons', RandomService='I3RandomService', InputMCTreeName="I3MCTree", OutputMCTreeName="I3MCTree") tray.Add(segments.PropagatePhotons, 'PropagatePhotons', RandomService='I3RandomService', HybridMode=args.hybrid, MaxParallelEvents=100, UseAllCPUCores=True, UseGPUs=args.use_gpu) #detector stuff tray.Add(DetectorSim, "DetectorSim", RandomService='I3RandomService', RunID=args.runnum, KeepPropagatedMCTree=True, KeepMCHits=True, KeepMCPulses=True, SkipNoiseGenerator=True, GCDFile=gcdFile, InputPESeriesMapName="I3MCPESeriesMap") #tray.Add(header, streams=[icetray.I3Frame.DAQ]) #tray.Add("I3NullSplitter") #clean the pulses tray.AddModule('I3MuonGun::WeightCalculatorModule', 'Weight', Model=model, Generator=generator) tray.AddModule('I3LCPulseCleaning', 'cleaning', OutputHLC=HLCpulses, OutputSLC='', Input=pulses) #now do the veto from icecube.filterscripts import filter_globals icetray.load("filterscripts", False) icetray.load("cscd-llh", False) tray.Add(find_primary) tray.Add(todet, surface=surface_det) tray.AddModule('HomogenizedQTot', 'qtot_totalDirty', Pulses=pulses, Output='HomogenizedQTotDirty', If=lambda frame: frame.Has('EnteringMuon_0')) tray.AddModule("VHESelfVeto", 'selfveto_3Dirty', VetoThreshold=3, VertexThreshold=3, pulses=pulses, OutputBool="VHESelfVeto_3Dirty", OutputVertexPos="VHESelfVetoVertexPos_3Dirty", OutputVertexTime="VHESelfVetoVertexTime_3Dirty", If=lambda frame: frame.Has('EnteringMuon_0')) tray.AddModule('HomogenizedQTot', 'qtot_totalClean', Pulses=HLCpulses, Output='HomogenizedQTotClean', If=lambda frame: frame.Has('EnteringMuon_0')) tray.AddModule("VHESelfVeto", 'selfveto_3Clean', VetoThreshold=3, VertexThreshold=3, pulses=HLCpulses, OutputBool="VHESelfVeto_3Clean", OutputVertexPos="VHESelfVetoVertexPos_3Clean", OutputVertexTime="VHESelfVetoVertexTime_3Clean", If=lambda frame: frame.Has('EnteringMuon_0')) #tray.Add(printer, If = lambda frame:frame.Has('EnteringMuon_0')) #tray.Add(print_gen, generator=generator) #write everything to file tray.AddModule( 'I3Writer', 'writer', Streams=[ icetray.I3Frame.Physics, #icetray.I3Frame.DAQ ], filename=args.out) tray.Execute() tray.Finish()
def Execute(self,stats): if not ipmodule.ParsingModule.Execute(self,stats): return 0 import icecube.icetray from icecube import icetray,dataclasses, phys_services, dataio from icecube.MuonGun import load_model, StaticSurfaceInjector, Cylinder, OffsetPowerLaw from icecube.MuonGun.segments import GenerateBundles from I3Tray import I3Tray, I3Units modelstr = self.GetParameter('model') emax = self.GetParameter("eprimarymax") emin = self.GetParameter("eprimarymin") length = self.GetParameter("length") radius = self.GetParameter("radius") cthmin = self.GetParameter('cthmin') cthmax = self.GetParameter('cthmax') gamma = self.GetParameter('gamma') seed = self.GetParameter('seed') nproc = self.GetParameter('nproc') procnum = self.GetParameter('procnum') gcdfile = self.GetParameter('gcdfile') # Instantiate a tray tray = I3Tray() # Configure IceTray services summary = dataclasses.I3MapStringDouble() tray.context["I3SummaryService"] = summary randomService = phys_services.I3SPRNGRandomService(seed, nproc, procnum) tray.context["I3RandomService"] = randomService # Use Hoerandel as a template for generating muons model = load_model(modelstr) # Generate only single muons, no bundles model.flux.max_multiplicity = 1 # Center the sampling surface on the barycenter of IC79 strings #surface = Cylinder(1600*I3Units.m, 800*I3Units.m, dataclasses.I3Position(31.25, 19.64, 0)) surface = Cylinder(length*I3Units.m, radius*I3Units.m) # Draw energies from an E^-2 power law broken at 1 TeV, from 10 TeV to 10 PeV spectrum = OffsetPowerLaw(gamma, 1*I3Units.TeV, 10*I3Units.TeV, 10*I3Units.PeV) # Set up the generator. This gets stored in a special frame for later reference generator = StaticSurfaceInjector(surface, model.flux, spectrum, model.radius) # Configure TraySegment that actually does stuff tray.AddSegment(GenerateBundles,"corsika-background", Generator=generator, RunNumber=self.runid, NEvents=self.nshowers, GCDFile=self.gcdfile, FromTime=dataclasses.I3Time(self.mjd), ToTime=dataclasses.I3Time(self.mjd)) def renameMCTree(frame): mctree = frame["I3MCTree"] del frame["I3MCTree"] frame["I3MCTree_preMuonProp"] = mctree tray.AddModule(renameMCTree, "renameMCTree", Streams=[icetray.I3Frame.DAQ]) tray.AddSegment(PropagateMuons,'propagator', RandomService=randomService, CylinderLength=self.length, CylinderRadius=self.radius, bs=self.bs, ph=self.ph, bb=self.bb, sh=self.sh) tray.AddModule(BasicCounter,"count_g", Streams = [icetray.I3Frame.DAQ], name = "Generated Events", Stats = stats) tray.AddModule("I3Writer","writer", filename = self.outputfile, streams =[icecube.icetray.I3Frame.DAQ] ) # Execute the Tray tray.Execute() del tray return 0
from clsim_server.client_module import GPU_Client from icecube import MuonGun, sim_services from icecube.icetray import I3Units from icecube.dataclasses import * from icecube.sim_services.propagation import get_propagators from icecube.MuonGun.segments import GenerateBundles from icecube.MuonGun import load_model, EnergyDependentSurfaceInjector, ConstantSurfaceScalingFunction, StaticSurfaceInjector, Cylinder, OffsetPowerLaw # base = expandvars('$I3_SRC/MuonGun/resources/scripts/fitting/') #Flux model model = MuonGun.load_model('GaisserH4a_atmod12_SIBYLL') model.flux.min_multiplicity = 1 model.flux.max_multiplicity = 1 #Inner and outher target surfaces outSurface = Cylinder(1600 * I3Units.m, 800 * I3Units.m) inSurface = Cylinder(500 * I3Units.m, 150 * I3Units.m, I3Position(46.3, -34.9, -300)) #Sets energy and spectral index of muons #Jackob's spectrum #spectrum = MuonGun.OffsetPowerLaw(5.0, 5e2, 200, 1e6) spectrum = MuonGun.OffsetPowerLaw(5.0, 7e2, int(sys.argv[2]), int(sys.argv[3])) #spectrum = MuonGun.OffsetPowerLaw(5.2, 7e2, 150, 1e5) #spectrum = MuonGun.OffsetPowerLaw(2, 1e3, 1e3, 1e5) #This version only aims at inSurface, but muons originate at outSurface scaling = MuonGun.ConstantSurfaceScalingFunction(inSurface) #generator = MuonGun.EnergyDependentSurfaceInjector(outSurface, model.flux, spectrum, model.radius, scaling,0,1) generator = MuonGun.EnergyDependentSurfaceInjector(outSurface, model.flux, spectrum, model.radius, scaling)
def main(): parser = argparse.ArgumentParser( description='Generates muons in IceCube with varying multiplicity') parser.add_argument('--nseed', default=1, type=int, help='seed for randomization') parser.add_argument('--model', default='Hoerandel5_atmod12_SIBYLL', type=str) parser.add_argument('--gcd', default='auto', type=str) parser.add_argument('--ice', default='SpiceLea', help='Either Spice1, SpiceMie or SpiceLea') parser.add_argument('--include-gcd', default=False, action='store_true', help='Include GCD in output') parser.add_argument( '--no-hybrid', action="store_false", default=False, dest='hybrid', help='do not perform a hybrid simulation (i.e. use clsim only)') parser.add_argument('--emin', default=1e3, type=float, help='Muon min energy (GeV)') parser.add_argument('--emax', default=1e6, type=float, help='Muon max energy (GeV)') parser.add_argument('--nevents', default=1e3, type=int, help='Number of events') parser.add_argument('--out', default='muongun.i3.gz', help='Output file') parser.add_argument('--runnum', default=1, type=int, help='Run number for this sim') parser.add_argument('--use-gpu', action='store_true', default=False, help='simulate using GPUs instead of CPU cores') args = parser.parse_args() if args.gcd == 'auto': gcdFilesDefault = { 'IC86': os.path.expandvars( '$I3_TESTDATA/sim/GeoCalibDetectorStatus_IC86.55697_corrected_V2.i3.gz' ), 'IC79': os.path.expandvars( '$I3_TESTDATA/sim/GeoCalibDetectorStatus_IC79.55380_L2a.i3.gz' ), } gcdFile = gcdFilesDefault[args.detector] else: gcdFile = args.gcd tray = I3Tray() tray.context['I3RandomService'] = phys_services.I3GSLRandomService( seed=args.nseed) gcd = expandvars( '$I3_TESTDATA/sim/GeoCalibDetectorStatus_IC86.55697_corrected_V2.i3.gz' ) model = load_model(args.model) surface = Cylinder(1600 * I3Units.m, 800 * I3Units.m, dataclasses.I3Position(0, 0, 0)) spectrum = OffsetPowerLaw(2, 0 * I3Units.TeV, args.emin * I3Units.GeV, args.emax * I3Units.GeV) generator = StaticSurfaceInjector(surface, model.flux, spectrum, model.radius) tray.AddSegment(GenerateBundles, 'MuonGenerator', Generator=generator, NEvents=args.nevents, GCDFile=gcd) tray.AddModule('I3MuonGun::WeightCalculatorModule', 'MuonWeight', Model=model, Generator=generator) icetray.logging.set_level_for_unit("I3PropagatorService", "TRACE") icetray.logging.set_level_for_unit("I3PropagatorMMC", "TRACE") icetray.logging.set_level_for_unit("I3PropagatorServiceMMC", "TRACE") tray.Add(segments.PropagateMuons, 'PropagateMuons', RandomService='I3RandomService') tray.Add(segments.PropagatePhotons, "PropagatePhotons", InputMCTree='I3MCTree', MaxParallelEvents=1, KeepIndividualMaps=False, IceModel=args.ice, UnshadowedFraction=0.9, HybridMode=args.hybrid, IgnoreMuons=False, UseAllCPUCores=True, UseGPUs=args.use_gpu) tray.Add(segments.DetectorSim, "DetectorSim", RandomService='I3RandomService', RunID=args.runnum, GCDFile=gcdFile, InputPESeriesMapName="I3MCPESeriesMap", KeepMCHits=True, KeepPropagatedMCTree=True, SkipNoiseGenerator=False) #tray.AddModule('I3PropagatorModule', 'propagator', PropagatorServices=make_propagators(), # RandomService='I3RandomService', RNGStateName="RNGState") tray.AddModule('I3Writer', 'writer', Streams=list(map(icetray.I3Frame.Stream, "SQP")), filename=args.model + "_" + args.out) tray.Execute()
def main(): #arguement parser parser = argparse.ArgumentParser( description='Generates muons in IceCube with varying multiplicity') parser.add_argument('--nseed', default=1, type=int, help='seed for randomization') #muongun args parser.add_argument('--model', default='GaisserH4a_atmod12_SIBYLL', type=str) parser.add_argument('--multiplicity', default=100, type=int, help='Maximum muon bundle multiplcity') parser.add_argument('--emin', default=1e3, type=float, help='Muon min energy (GeV)') parser.add_argument('--emax', default=1e7, type=float, help='Muon max energy (GeV)') parser.add_argument('--nevents', default=1000, type=int, help='Number of events') parser.add_argument('--nfiles', default=1, type=int, help='Number of files to generate') parser.add_argument('--out', default='muongun.i3.gz', help='Output file') parser.add_argument('--runnum', default=1, type=int, help='Run number for this sim') #detector args parser.add_argument( '--gcd', default=os.path.expandvars( '$I3_TESTDATA/sim/GeoCalibDetectorStatus_IC86.55697_corrected_V2.i3.gz' ), type=str, help='gcd file') parser.add_argument( '--no-hybrid', action="store_false", default=False, dest='hybrid', help='do not perform a hybrid simulation (i.e. use clsim only)') parser.add_argument('--use-gpu', action='store_true', default=False, help='simulate using GPUs instead of CPU cores') args = parser.parse_args() #setup muongun parameters gcdFile = args.gcd model = load_model(args.model) flux = model.flux radii = model.radius energies = model.energy #surface = MuonGun.ExtrudedPolygon.from_file(gcdFile, padding=60*I3Units.m) surface = Cylinder(1200 * I3Units.m, 600 * I3Units.m, dataclasses.I3Position(0, 0, 0)) generator = NaturalRateInjector(surface, flux, energies) #spectrum = OffsetPowerLaw(1, 1*I3Units.TeV, args.emin, args.emax) #generator = StaticSurfaceInjector(surface, model.flux, spectrum, model.radius) #setup I3Tray tray = I3Tray() tray.context['I3RandomService'] = phys_services.I3GSLRandomService( seed=args.nseed) #generate events #tray.AddModule("I3MuonGun::GeneratorModule", 'MuonGenerator', # Generator=generator) tray.AddSegment(GenerateBundles, 'MuonGenerator', Generator=generator, RunNumber=args.runnum, NEvents=args.nevents, GCDFile=gcdFile) #propagate particles tray.Add(segments.PropagateMuons, 'PropagateMuons', RandomService='I3RandomService', InputMCTreeName="I3MCTree", OutputMCTreeName="I3MCTree") tray.Add(header, streams=[icetray.I3Frame.DAQ]) tray.Add("I3NullSplitter") #more muongun stuff tray.AddModule('I3MuonGun::WeightCalculatorModule', 'Weight', Model=BundleModel(flux, radii, energies), Generator=args.nfiles * args.nevents * generator) tray.AddModule('I3MuonGun::WeightCalculatorModule', 'Biased_Weight', Model=model, Generator=args.nfiles * args.nevents * generator) tray.Add(find_primary) surface_det = MuonGun.ExtrudedPolygon.from_file(gcdFile) tray.Add(todet, surface=surface_det) #do an N > 0 cut def ncut(frame): if frame.Has('EnteringMuon_0'): return True else: return False tray.AddModule(ncut, 'ncut') #effective area def eff_area(frame, generator): mctree = frame['I3MCTree'] primary = mctree.primaries[0] muon = mctree.get_daughters(primary)[0] bundle = BundleConfiguration([BundleEntry(0, muon.energy)]) fluence = generator.generated_events(primary, bundle) if fluence > 0.: area = 1. / fluence frame["MCMuon"] = muon frame["MuonEffectiveArea"] = dataclasses.I3Double(area) else: icecube.icetray.logging.log_warn( "Fluence value of {0:f} encountered.".format(fluence), unit="GenerateSingleMuons") return True tray.AddModule(eff_area, 'effective area', generator=generator) #detector stuff pulses = 'InIcePulses' #tray.Add(segments.PropagatePhotons, 'PropagatePhotons', # RandomService='I3RandomService', # HybridMode=args.hybrid, # MaxParallelEvents=100, # UseAllCPUCores=True, # UseGPUs=args.use_gpu) #tray.Add(segments.DetectorSim, "DetectorSim", # RandomService='I3RandomService', # RunID=args.runnum, # KeepPropagatedMCTree=True, # KeepMCHits=True, # KeepMCPulses=True, # SkipNoiseGenerator=True, # GCDFile=gcdFile, # InputPESeriesMapName="I3MCPESeriesMap") #write everything to file tray.AddModule( 'I3Writer', 'writer', Streams=[ icetray.I3Frame.Physics, icetray.I3Frame.Simulation, #icetray.I3Frame.DAQ ], filename=args.out) tray.Execute() tray.Finish()
tray = I3Tray() randomService = phys_services.I3SPRNGRandomService(1, 10000, 1) tray.context['I3RandomService'] = randomService from icecube.icetray import I3Units from icecube.MuonGun import load_model, StaticSurfaceInjector, Cylinder, OffsetPowerLaw from icecube.MuonGun.segments import GenerateBundles # Use Hoerandel as a template for generating muons model = load_model('Hoerandel5_atmod12_SIBYLL') # Generate only single muons, no bundles model.flux.max_multiplicity = 1 # Center the sampling surface on the barycenter of IC79 strings surface = Cylinder(1600 * I3Units.m, 800 * I3Units.m, dataclasses.I3Position(31.25, 19.64, 0)) surface = Cylinder(1600 * I3Units.m, 800 * I3Units.m) # Draw energies from an E^-2 power law broken at 1 TeV, from 10 TeV to 10 PeV spectrum = OffsetPowerLaw(2, 1 * I3Units.TeV, 10 * I3Units.TeV, 10 * I3Units.PeV) # Set up the generator. This gets stored in a special frame for later reference generator = StaticSurfaceInjector(surface, model.flux, spectrum, model.radius) tray.AddSegment(GenerateBundles, 'MuonGenerator', Generator=generator, NEvents=10000, GCDFile=gcd) icetray.logging.set_level_for_unit("I3PropagatorService", "TRACE") icetray.logging.set_level_for_unit("I3PropagatorMMC", "TRACE")
tray.AddModule('I3Reader', 'reader', FilenameList=filenamelist) #Add muon weight that I guess I should have added before from icecube import MuonGun, sim_services from icecube.icetray import I3Units from icecube.dataclasses import * from icecube.sim_services.propagation import get_propagators from icecube.MuonGun.segments import GenerateBundles from icecube.MuonGun import load_model, EnergyDependentSurfaceInjector, ConstantSurfaceScalingFunction, StaticSurfaceInjector, Cylinder, OffsetPowerLaw #Flux model model = MuonGun.load_model('GaisserH4a_atmod12_SIBYLL') model.flux.min_multiplicity = 1 model.flux.max_multiplicity = 1 #Inner and outher target surfaces outSurface = Cylinder(1600 * I3Units.m, 800 * I3Units.m) inSurface = Cylinder(700 * I3Units.m, 125 * I3Units.m, I3Position(29.3, 52.6, -150)) #Sets energy and spectral index of muons spectrum = MuonGun.OffsetPowerLaw(5.2, 7e2, 200, 1e6) #This version only aims at inSurface, but muons originate at outSurface scaling = MuonGun.ConstantSurfaceScalingFunction(inSurface) generator = MuonGun.EnergyDependentSurfaceInjector(outSurface, model.flux, spectrum, model.radius, scaling, 0, 1) tray.AddModule( 'I3MuonGun::WeightCalculatorModule', 'MuonWeight', Model=model, Generator=generator,
def main(): #arguement parser parser = argparse.ArgumentParser( description='Generates muons in IceCube with varying multiplicity') parser.add_argument('inp', nargs='+') parser.add_argument('--nseed', default=1, type=int, help='seed for randomization') parser.add_argument('--out', default='corsika', help='Output file') parser.add_argument('--runnum', default=1, type=int, help='Run number for this sim') parser.add_argument('--did', default=20694, type=int, help='Simpord Number for this sim') parser.add_argument('--nfiles', default=1, type=int, help='Number of files to generate') #detector args parser.add_argument( '--gcd', default=os.path.expandvars( '$I3_TESTDATA/sim/GeoCalibDetectorStatus_IC86.55697_corrected_V2.i3.gz' ), type=str, help='gcd file') args = parser.parse_args() #geometry parameters gcdFile = args.gcd surface = Cylinder(1600 * I3Units.m, 800 * I3Units.m, dataclasses.I3Position(0, 0, 0)) surface_det = MuonGun.ExtrudedPolygon.from_file(gcdFile) #setup reconstruction parameters pulses = 'InIcePulses' HLCpulses = 'HLCInIcePulses' #setup I3Tray tray = I3Tray() tray.context['I3RandomService'] = phys_services.I3GSLRandomService( seed=args.nseed) #tray.context['I3RandomService'] = phys_services.I3SPRNGRandomService(seed = args.nseed) infiles = args.inp tray.Add('I3Reader', Filenamelist=[args.gcd] + infiles) #weighting tray.Add(header, streams=[icetray.I3Frame.DAQ]) tray.Add("I3NullSplitter") generator = weighting.FiveComponent(947487, 1000, 1e+07, normalization=[5, 2.5, 1.1, 1.2, 1], gamma=[-2.65, -2.6, -2.6, -2.6, -2.6], height=1000, radius=500, LowerCutoffType='EnergyPerNucleon', UpperCutoffType='EnergyPerNucleon') nfiles = args.nfiles generator *= nfiles flux = GaisserH4a() tray.Add(getweights, generator=generator, flux=flux) #find intersecting muons tray.Add(muonstodet, surface=surface_det) tray.Add(primarytodet, surface=surface_det) #do an N > 0 cut global total_events total_events = 0 global passed_events passed_events = 0 def ncut(frame): global total_events global passed_events total_events += 1 if frame.Has('EnteringMuon_0'): passed_events += 1 return True else: return False tray.AddModule(ncut, 'ncut') #write everything to file tray.AddModule( 'I3Writer', 'writer', Streams=[ icetray.I3Frame.Physics, #icetray.I3Frame.DAQ ], filename=args.out + "_" + str(args.nseed) + ".i3.gz") tray.Execute() tray.Finish() print "totol events processed: " + str(total_events) print "total events with one muon: " + str(passed_events) print "efficiency: %0.2f" % (1. * passed_events / total_events) end_time = time.asctime() print 'Ended:', end_time
#!/usr/bin/env python import icecube from icecube import dataclasses, dataio, icetray from icecube import MuonGun from icecube.MuonGun import load_model, EnergyDependentSurfaceInjector, ConstantSurfaceScalingFunction, StaticSurfaceInjector, Cylinder, OffsetPowerLaw import numpy, math from I3Tray import * file_list = sys.argv[2:] n_files = len(file_list) dcSurface = Cylinder(500*I3Units.m, 150*I3Units.m, dataclasses.I3Position(29.3,52.6,-300)) icSurface = Cylinder(1600*I3Units.m, 800*I3Units.m) def SurfEneCut(frame): dcPart = MuonGun.muons_at_surface(frame,dcSurface) max_ene = 0 # if(frame.Has('I3MCTree')): # if(frame["I3MCTree"].most_energetic_muon): # if(frame["I3MCTree"].most_energetic_muon.energy<500): # return False # else: # return False # else: # return False if(len(dcPart)>0): for i in xrange(len(dcPart)): if(dcPart[i].energy>max_ene):