Esempio n. 1
0
    def Process(self):
        gcd = dataio.I3File(self.gcdfile, 'R')
        while (gcd.more()):
            frame = gcd.pop_frame()
            if (frame.Stop == icetray.I3Frame.Geometry):
                geo = frame["I3Geometry"]
            self.PushFrame(frame)
        gcd.close()
        #now deliver artificial testcase
        #make a Q-frame
        Qrecomap = dataclasses.I3RecoPulseSeriesMap()
        recopulse1 = dataclasses.I3RecoPulse()
        recopulse1.time = 0.
        recopulse1.charge = 1.
        recopulse2 = dataclasses.I3RecoPulse()
        recopulse2.time = 1000. / I3Constants.c  #=3335.ns
        recopulse2.charge = 2.
        Qrecomap[icetray.OMKey(26, 1)] = [recopulse1]
        Qrecomap[icetray.OMKey(27, 1)] = [recopulse1]
        Qrecomap[icetray.OMKey(35, 1)] = [recopulse1]
        Qrecomap[icetray.OMKey(37, 1)] = [recopulse1]
        Qrecomap[icetray.OMKey(45, 1)] = [recopulse1]
        Qrecomap[icetray.OMKey(46, 1)] = [recopulse1]
        Qrecomap[icetray.OMKey(26, 60)] = [recopulse2]
        Qrecomap[icetray.OMKey(27, 60)] = [recopulse2]
        Qrecomap[icetray.OMKey(35, 60)] = [recopulse2]
        Qrecomap[icetray.OMKey(37, 60)] = [recopulse2]
        Qrecomap[icetray.OMKey(45, 60)] = [recopulse2]
        Qrecomap[icetray.OMKey(46, 60)] = [recopulse2]

        Qframe = icetray.I3Frame(icetray.I3Frame.DAQ)
        Qeh = dataclasses.I3EventHeader()
        Qeh.start_time = (dataclasses.I3Time(2011, 0))
        Qeh.end_time = (dataclasses.I3Time(2011, 2))
        Qeh.run_id = 1
        Qeh.event_id = 1
        Qframe.Put("I3EventHeader", Qeh)

        Qframe.Put(OrgPulses, Qrecomap)
        Qframe.Put(SplitName + "SplitCount", icetray.I3Int(2))
        Qframe.Put(SplitName + "ReducedCount", icetray.I3Int(0))
        self.PushFrame(Qframe)

        #now make the first p-frame containing one I3RecoPulse
        P1frame = icetray.I3Frame(icetray.I3Frame.Physics)
        P1eh = dataclasses.I3EventHeader()
        P1eh.start_time = (dataclasses.I3Time(2011, 0))
        P1eh.end_time = (dataclasses.I3Time(2011, 1))
        P1eh.run_id = 1
        P1eh.event_id = 1
        P1eh.sub_event_stream = "split"
        P1eh.sub_event_id = 0
        P1frame.Put("I3EventHeader", P1eh)
        P1recomap = dataclasses.I3RecoPulseSeriesMap()

        P1recomap[icetray.OMKey(26, 1)] = [recopulse1]
        P1recomap[icetray.OMKey(27, 1)] = [recopulse1]
        P1recomap[icetray.OMKey(35, 1)] = [recopulse1]
        P1recomap[icetray.OMKey(37, 1)] = [recopulse1]
        P1recomap[icetray.OMKey(45, 1)] = [recopulse1]
        P1recomap[icetray.OMKey(46, 1)] = [recopulse1]

        P1recomask = dataclasses.I3RecoPulseSeriesMapMask(
            Qframe, OrgPulses, P1recomap)
        P1frame.Put(SplitPulses, P1recomask)
        P1fit = dataclasses.I3Particle(
            dataclasses.I3Particle.ParticleShape.InfiniteTrack)
        P1fit.time = -455. * I3Units.ns
        P1fit.pos = geo.omgeo[icetray.OMKey(36, 1)].position
        P1fit.dir = dataclasses.I3Direction(0., 0.)  #straight down
        P1fit.fit_status = dataclasses.I3Particle.OK
        P1frame.Put("Fit", P1fit)
        self.PushFrame(P1frame)

        #now make the second p-frame containing one I3RecoPulse
        P2frame = icetray.I3Frame(icetray.I3Frame.Physics)
        P2eh = dataclasses.I3EventHeader()
        P2eh.start_time = (dataclasses.I3Time(2011, 1))
        P2eh.end_time = (dataclasses.I3Time(2011, 2))
        P2eh.run_id = 1
        P2eh.event_id = 1
        P2eh.sub_event_stream = SplitName
        P2eh.sub_event_id = 1
        P2frame.Put("I3EventHeader", P2eh)
        P2recomap = dataclasses.I3RecoPulseSeriesMap()

        P2recomap[icetray.OMKey(26, 60)] = [recopulse2]
        P2recomap[icetray.OMKey(27, 60)] = [recopulse2]
        P2recomap[icetray.OMKey(35, 60)] = [recopulse2]
        P2recomap[icetray.OMKey(37, 60)] = [recopulse2]
        P2recomap[icetray.OMKey(45, 60)] = [recopulse2]
        P2recomap[icetray.OMKey(46, 60)] = [recopulse2]

        P2recomask = dataclasses.I3RecoPulseSeriesMapMask(
            Qframe, OrgPulses, P2recomap)
        P2frame.Put(SplitPulses, P2recomask)

        P2fit = dataclasses.I3Particle(
            dataclasses.I3Particle.ParticleShape.InfiniteTrack)
        P2fit.time = 1000. / I3Constants.c - 454. * I3Units.ns
        P2fit.pos = geo.omgeo[icetray.OMKey(36, 60)].position
        P2fit.dir = dataclasses.I3Direction(0, 0.)  #straight up
        P2fit.fit_status = dataclasses.I3Particle.OK
        P2frame.Put("Fit", P2fit)
        self.PushFrame(P2frame)

        Hframe = icetray.I3Frame(icetray.I3Frame.Physics)
        Heh = dataclasses.I3EventHeader()
        Heh.start_time = (dataclasses.I3Time(2011, 0))
        Heh.end_time = (dataclasses.I3Time(2011, 2))
        Heh.run_id = 1
        Heh.event_id = 1
        Heh.sub_event_stream = HypoName
        Heh.sub_event_id = 0
        Hframe.Put("I3EventHeader", Heh)
        Hrecomap = dataclasses.I3RecoPulseSeriesMap()

        Hrecomap[icetray.OMKey(26, 1)] = [recopulse1]  #ring top
        Hrecomap[icetray.OMKey(27, 1)] = [recopulse1]
        Hrecomap[icetray.OMKey(35, 1)] = [recopulse1]
        Hrecomap[icetray.OMKey(37, 1)] = [recopulse1]
        Hrecomap[icetray.OMKey(45, 1)] = [recopulse1]
        Hrecomap[icetray.OMKey(46, 1)] = [recopulse1]
        Hrecomap[icetray.OMKey(26, 60)] = [recopulse2]  #ring bottom
        Hrecomap[icetray.OMKey(27, 60)] = [recopulse2]
        Hrecomap[icetray.OMKey(35, 60)] = [recopulse2]
        Hrecomap[icetray.OMKey(37, 60)] = [recopulse2]
        Hrecomap[icetray.OMKey(45, 60)] = [recopulse2]
        Hrecomap[icetray.OMKey(46, 60)] = [recopulse2]

        Hrecomask = dataclasses.I3RecoPulseSeriesMapMask(
            Qframe, OrgPulses, Hrecomap)
        Hframe.Put(SplitPulses, Hrecomask)
        Hcf = dataclasses.I3MapStringVectorDouble()
        Hcf["split"] = [0, 1]
        Hframe.Put("CS_CreatedFrom", Hcf)
        Hfit = dataclasses.I3Particle(
            dataclasses.I3Particle.ParticleShape.InfiniteTrack)
        Hfit.time = -454. * I3Units.ns
        Hfit.pos = geo.omgeo[icetray.OMKey(36, 1)].position
        Hfit.dir = dataclasses.I3Direction(0., 0.)
        Hfit.fit_status = dataclasses.I3Particle.OK
        Hframe.Put("HFit", Hfit)
        self.PushFrame(Hframe)

        self.RequestSuspension()
Esempio n. 2
0
 def Process(self):
   gcd = dataio.I3File(self.gcdfile, 'R')
   while (gcd.more()):
     frame = gcd.pop_frame()
     self.PushFrame(frame)
   gcd.close()
   #now deliver artificial testcase
   #make a Q-frame
   Qframe = icetray.I3Frame(icetray.I3Frame.DAQ)
   Qeh = dataclasses.I3EventHeader()
   Qeh.start_time = (dataclasses.I3Time(2011, 0))
   Qeh.end_time = (dataclasses.I3Time(2011, 2))
   Qeh.run_id = 1
   Qeh.event_id = 1
   Qframe.Put("I3EventHeader", Qeh)
   Qrecomap = dataclasses.I3RecoPulseSeriesMap()
   recopulse1 = dataclasses.I3RecoPulse()
   recopulse1.time = 0
   recopulse1.charge = 1
   recopulse2 = dataclasses.I3RecoPulse()
   recopulse2.time = 1
   recopulse2.charge = 2
   Qrecomap[icetray.OMKey(1,1)] = [recopulse1]
   Qrecomap[icetray.OMKey(2,2)] = [recopulse2]
   Qframe.Put(OrgPulses, Qrecomap)
   Qframe.Put(SplitName+"SplitCount", icetray.I3Int(2))
   Qframe.Put(SplitName+"ReducedCount", icetray.I3Int(0))
   self.PushFrame(Qframe)
   #now make the first p-frame containing one I3RecoPulse
   P1frame = icetray.I3Frame(icetray.I3Frame.Physics)
   P1eh = dataclasses.I3EventHeader()
   P1eh.start_time = (dataclasses.I3Time(2011, 0))
   P1eh.end_time = (dataclasses.I3Time(2011, 1))
   P1eh.run_id = 1
   P1eh.event_id = 1
   P1eh.sub_event_stream = "split"
   P1eh.sub_event_id = 0
   P1frame.Put("I3EventHeader", P1eh)
   P1recomap = dataclasses.I3RecoPulseSeriesMap()
   P1recomap[icetray.OMKey(1,1)] = [recopulse1]
   P1recomask = dataclasses.I3RecoPulseSeriesMapMask(Qframe, OrgPulses, Qrecomap)
   P1frame.Put(SplitPulses, P1recomask)
   P1fit = dataclasses.I3Particle()
   P1fit.pos= dataclasses.I3Position(0.,0., CriticalDistance)
   P1fit.dir= dataclasses.I3Direction(0., CriticalAngle)
   P1fit.fit_status = dataclasses.I3Particle.OK
   P1frame.Put("Fit", P1fit)
   self.PushFrame(P1frame)
   #now make the second p-frame containing one I3RecoPulse
   P2frame = icetray.I3Frame(icetray.I3Frame.Physics)
   P2eh = dataclasses.I3EventHeader()
   P2eh.start_time = (dataclasses.I3Time(2011, 1))
   P2eh.end_time = (dataclasses.I3Time(2011, 2))
   P2eh.run_id = 1
   P2eh.event_id = 1
   P2eh.sub_event_stream = "split"
   P2eh.sub_event_id = 1
   P2frame.Put("I3EventHeader", P2eh)
   P2recomap = dataclasses.I3RecoPulseSeriesMap()
   P2recomap[icetray.OMKey(2,2)] = [recopulse2]
   P2recomask = dataclasses.I3RecoPulseSeriesMapMask(Qframe, OrgPulses, P2recomap)
   P2frame.Put(SplitPulses, P2recomask)
   P2fit = dataclasses.I3Particle()
   P2fit.pos= dataclasses.I3Position(0.,0., CriticalDistance)
   P2fit.dir= dataclasses.I3Direction(0., -CriticalAngle)
   P2fit.fit_status = dataclasses.I3Particle.OK
   P2frame.Put("Fit", P2fit)
   self.PushFrame(P2frame)
   Hframe = icetray.I3Frame(icetray.I3Frame.Physics)
   Heh = dataclasses.I3EventHeader()
   Heh.start_time = (dataclasses.I3Time(2011, 0))
   Heh.end_time = (dataclasses.I3Time(2011, 2))
   Heh.run_id = 1
   Heh.event_id = 1
   Heh.sub_event_stream = HypoName
   Heh.sub_event_id = 0
   Hframe.Put("I3EventHeader", Heh)
   Hrecomap = dataclasses.I3RecoPulseSeriesMap()
   Hrecomap[icetray.OMKey(1,1)] = [recopulse1]
   Hrecomap[icetray.OMKey(2,2)] = [recopulse2]
   Hrecomask = dataclasses.I3RecoPulseSeriesMapMask(Qframe, OrgPulses, Hrecomap)
   Hframe.Put(SplitPulses, Hrecomask)
   Hcf = dataclasses.I3MapStringVectorDouble()
   Hcf["split"]=[0,1]
   Hframe.Put("CS_CreatedFrom", Hcf)
   Hfit = dataclasses.I3Particle()
   Hfit.time= 0
   Hfit.pos= dataclasses.I3Position(0.,0.,0.)
   Hfit.dir= dataclasses.I3Direction(0., 0.)
   Hfit.fit_status = dataclasses.I3Particle.OK
   Hframe.Put("HFit", Hfit)
   self.PushFrame(Hframe)
   
   self.RequestSuspension()
Esempio n. 3
0
def main(inputFiles, outfile, n=None, outputLevel=2):
    import math
    import numpy

    from I3Tray import I3Tray
    from icecube import icetray, dataclasses, dataio, phys_services, rock_bottom, gulliver, lilliput

    icetray.set_log_level_for_unit('RockBottom',
                                   icetray.I3LogLevel(outputLevel))
    icetray.set_log_level_for_unit('I3TwoLDFSignalModel',
                                   icetray.I3LogLevel(outputLevel))
    icetray.set_log_level_for_unit('I3TopLeanFitter',
                                   icetray.I3LogLevel(outputLevel))
    icetray.set_log_level_for_unit('I3TopSeedService',
                                   icetray.I3LogLevel(outputLevel))

    gcdfile = [options.gcd]

    # Instantiate a tray
    tray = I3Tray()

    HLCPulses = 'OfflineIceTopSelectedHLC'
    SLCPulses = 'OfflineIceTopSelectedSLC'

    tray.AddService(
        'I3GulliverMinuitFactory',
        'Minuit',
        MinuitPrintLevel=-2,
        FlatnessCheck=True,
        Algorithm='SIMPLEX',
        MaxIterations=2500,
        MinuitStrategy=2,
        Tolerance=0.01,
    )

    tray.AddService(
        'TwoLDFSignalModel',
        'TwoLDFSignalModel',
        TankResponseTablesDir=
        '/data/icet0/gonzalez/IceCubeSoftware/Sandbox/rock_bottom/resources/data/tank_response'
    )

    tray.AddService('I3TopLDFLikelihoodFactory',
                    'TwoLDFLikelihood',
                    Model='TwoLDFSignalModel',
                    HLCPulses=HLCPulses,
                    SLCPulses=SLCPulses,
                    SaturatedPulses='',
                    IgnoreTanks='')

    tray.AddService('I3TopTrivialGulliverParametrizationFactory',
                    'TwoLDFParam',
                    Parameters=dataclasses.I3MapStringVectorDouble({
                        'S_ref': (numpy.nan, numpy.nan, 2),
                        'rho_mu_ref': [1.],
                        'age': [0.8]
                    }))

    tray.AddService(
        'I3TopSeedServiceFactory',
        'TwoLDFSeed',
        Seed='Laputop',
        HLCPulses=HLCPulses,
        SLCPulses=SLCPulses,
        SignalModel='TwoLDFSignalModel',
    )

    tray.AddModule('I3Reader', 'Reader', FilenameList=gcdfile + inputFiles)

    #def select(frame): return True
    #tray.AddSegment(select, 'selection')

    tray.AddModule('I3TopLeanFitter',
                   'TwoLDFLeanFitter',
                   Minimizer='Minuit',
                   Parametrization='TwoLDFParam',
                   LogLikelihood='TwoLDFLikelihood',
                   Seed='TwoLDFSeed')

    tray.AddModule('I3Writer',
                   'i3-writer',
                   Filename=outfile,
                   DropOrphanStreams=[icetray.I3Frame.DAQ],
                   streams=[icetray.I3Frame.DAQ, icetray.I3Frame.Physics])

    tray.AddModule('TrashCan', 'Done')

    # Execute the Tray
    if n is None:
        tray.Execute()
    else:
        tray.Execute(n)
    tray.Finish()