示例#1
0
def main(opts):
    ntpl1 = ntuple.TrackingNtuple(opts.file1)
    ntpl2 = ntuple.TrackingNtuple(opts.file2)

    print("--- %s" % opts.file1)
    print("+++ %s" % opts.file2)

    printTrack = ntuple.TrackPrinter(
        trackingParticlePrinter=ntuple.TrackingParticlePrinter(
            parentage=False),
        diffForTwiki=opts.twiki)

    if opts.outOfOrder:
        outOfOrder(opts, ntpl1, ntpl2, printTrack)
    else:
        inOrder(opts, ntpl1, ntpl2, printTrack)
示例#2
0
def main(opts):
    if opts.track is None and opts.trackingParticle is None and opts.seed is None and opts.pixelHit is None and opts.stripHit is None:
        return

    ntpl = ntuple.TrackingNtuple(opts.file)

    if opts.entry is not None:
        event = ntpl.getEvent(opts.entry)
        print event.eventIdStr()
    elif opts.event is not None:
        event = findEvent(ntpl, opts.event)
        print "Entry %d" % event.entry()

    hasHits = ntpl.hasHits()
    hasSeeds = ntpl.hasSeeds()

    if not hasSeeds and opts.seed is not None:
        print "Ntuple %s does not have seeds saved!" % opts.file
        return
    if not hasHits and (opts.pixelHit is not None
                        or opts.stripHit is not None):
        print "Ntuple %s does not have hits saved!" % opts.file
        return

    seedArgs = dict(hits=hasHits, bestMatchingTrackingParticle=hasHits)
    trackArgs = dict(hits=hasHits, bestMatchingTrackingParticle=hasHits)
    tpArgs = dict(hits=hasHits, bestMatchingTrack=hasHits)
    if not hasSeeds:
        trackArgs["seedPrinter"] = None
        tpArgs["seedPrinter"] = None
    elif not hasHits:
        trackArgs["seedPrinter"] = ntuple.SeedPrinter(**seedArgs)
        tpArgs["seedPrinter"] = ntuple.SeedPrinter(**seedArgs)

    printSeed = ntuple.SeedPrinter(
        trackingParticles=True,
        trackingParticlePrinter=ntuple.TrackingParticlePrinter(**tpArgs),
        **seedArgs)
    printTrack = ntuple.TrackPrinter(
        trackingParticlePrinter=ntuple.TrackingParticlePrinter(**tpArgs),
        **trackArgs)
    printTrackingParticle = ntuple.TrackingParticlePrinter(
        trackPrinter=ntuple.TrackPrinter(**trackArgs), **tpArgs)

    if opts.track is not None:
        trks = event.tracks()
        if opts.track >= len(trks):
            print "You requested track %d, but this event has only %d tracks" % (
                opts.track, len(trks))
            return
        trk = trks[opts.track]
        printTrack(trk)

    if opts.trackingParticle is not None:
        tps = event.trackingParticles()
        if opts.trackingParticle >= len(tps):
            print "You requested TrackingParticle %d, but this event has ony %d TrackingParticles" % (
                opts.trackingParticle, len(tps))
            return
        tp = tps[opts.trackingParticle]
        printTrackingParticle(tp)

    if opts.seed is not None:
        seeds = event.seeds()
        if opts.seedIteration is not None:
            algo = getattr(ntuple.Algo, opts.seedIteration)
            if opts.seed >= seeds.nSeedsForAlgo(algo):
                print "You requested seed %d for algo %s, but this event has only %d seeds for that algo" % (
                    opts.seed, opts.seedIteration, seeds.nSeedsForAlgo(algo))
                return
            seed = seeds.seedForAlgo(algo, opts.seed)
        else:
            if opts.seed >= len(seeds):
                print "You requested seed %d, but this event has only %d seeds" % (
                    opts.seed, len(seeds))
                return
            seed = seeds[opts.seed]
        printSeed(seed)

    if opts.pixelHit is not None:
        hits = event.pixelHits()
        if opts.pixelHit >= len(hits):
            print "You requested pixel hit %d, but this event has only %d pixel hits" % (
                opts.pixelHit, len(hits))
            return

        hit = hits[opts.pixelHit]
        print "Pixel hit %d tracks" % opts.pixelHit
        for t in hit.tracks():
            printTrack(t)
        if hasSeeds:
            print "Pixel hit %d seeds" % opts.pixelHit
            for s in hit.seeds():
                printSeed(s)

    if opts.stripHit is not None:
        hits = event.stripHits()
        if opts.stripHit >= len(hits):
            print "You requested strip hit %d, but this event has only %d strip hits" % (
                opts.stripHit, len(hits))
            return
        hit = hits[opts.stripHit]
        print "Strip hit %d tracks" % opts.stripHit
        for t in hit.tracks():
            printTrack(t)
        if hasSeeds:
            print "Strip hit %d seeds" % opts.stripHit
            for s in hit.seeds():
                printSeed(s)
def main(opts):
    if opts.track is None and opts.trackingParticle is None and opts.seed is None and opts.pixelHit is None and opts.stripHit is None:
        return

    ntpl = ntuple.TrackingNtuple(opts.file)

    if opts.entry is not None:
        event = ntpl.getEvent(opts.entry)
        print event.eventIdStr()
    elif opts.event is not None:
        event = findEvent(ntpl, opts.event)
        print "Entry %d" % event.entry()

    hasHits = ntpl.hasHits()
    hasSeeds = ntpl.hasSeeds()

    if not hasSeeds and opts.seed is not None:
        print "Ntuple %s does not have seeds saved!" % opts.file
        return
    if not hasHits and (opts.pixelHit is not None
                        or opts.stripHit is not None):
        print "Ntuple %s does not have hits saved!" % opts.file
        return

    seedArgs = dict(hits=hasHits, bestMatchingTrackingParticle=hasHits)
    trackArgs = dict(hits=hasHits, bestMatchingTrackingParticle=hasHits)
    tpArgs = dict(hits=hasHits, bestMatchingTrack=hasHits)
    if not hasSeeds:
        trackArgs["seedPrinter"] = None
        tpArgs["seedPrinter"] = None
    elif not hasHits:
        trackArgs["seedPrinter"] = ntuple.SeedPrinter(**seedArgs)
        tpArgs["seedPrinter"] = ntuple.SeedPrinter(**seedArgs)

    printSeed = ntuple.SeedPrinter(
        trackingParticles=True,
        trackingParticlePrinter=ntuple.TrackingParticlePrinter(**tpArgs),
        **seedArgs)
    printTrack = ntuple.TrackPrinter(
        trackingParticlePrinter=ntuple.TrackingParticlePrinter(**tpArgs),
        **trackArgs)
    printTrackingParticle = ntuple.TrackingParticlePrinter(
        trackPrinter=ntuple.TrackPrinter(**trackArgs), **tpArgs)

    if opts.track is not None:
        trk = event.tracks()[opts.track]
        printTrack(trk)

    if opts.trackingParticle is not None:
        tp = event.trackingParticles()[opts.trackingParticle]
        printTrackingParticle(tp)

    if opts.seed is not None:
        seeds = event.seeds()
        if opts.seedIteration is not None:
            seed = seeds.seedForAlgo(getattr(ntuple.Algo, opts.seedIteration),
                                     opts.seed)
        else:
            seed = seeds[opts.seed]
        printSeed(seed)

    if opts.pixelHit is not None:
        hit = event.pixelHits()[opts.pixelHit]
        print "Pixel hit %d tracks" % opts.pixelHit
        for t in hit.tracks():
            printTrack(t)
        if hasSeeds:
            print "Pixel hit %d seeds" % opts.pixelHit
            for t in hit.seeds():
                printSeed(s)

    if opts.stripHit is not None:
        hit = event.stripHits()[opts.stripHit]
        print "Strip hit %d tracks" % opts.stripHit
        for t in hit.tracks():
            printTrack(t)
        if hasSeeds:
            print "Strip hit %d seeds" % opts.stripHit
            for t in hit.seeds():
                printSeed(s)