else:
    iolcv = larcv.IOManager(larcv.IOManager.kREAD, "larcv",
                            larcv.IOManager.kTickForward)
iolcv.add_in_file(args.input_larcv)
iolcv.reverse_all_products()
iolcv.initialize()

nentries = iolcv.get_n_entries()
print "Number of entries: ", nentries
if args.nentries >= 0 and args.nentries < nentries:
    nentries = args.nentries

print "Start loop."
tmp = rt.TFile(args.output, "recreate")

badchmaker = ublarcvapp.EmptyChannelAlgo()
ev_triplet = std.vector("larflow::prep::PrepMatchTriplets")(1)
kpana = larflow.keypoints.PrepKeypointData()
kpana.setADCimageTreeName(args.adc)
kpana.defineAnaTree()

ssnet = larflow.prep.PrepSSNetTriplet()
ssnet.defineAnaTree()

if args.save_triplets:
    triptree = rt.TTree("larmatchtriplet", "LArMatch triplets")
    triptree.Branch("triplet_v", ev_triplet)

start = time.time()

nrun = 0
    weights = [
        "sparseinfill_uplane_test.tar", "sparseinfill_vplane_test.tar",
        "sparseinfill_yplane_test.tar"
    ]

    # splitter
    cfg = "../infill_split.cfg"

    pset = larcv.CreatePSetFromFile(cfg, "UBSplitDetector")
    print(pset.dump())

    ubsplit = ublarcvapp.UBSplitDetector()
    ubsplit.configure(pset)
    ubsplit.initialize()

    ubbadch = ublarcvapp.EmptyChannelAlgo()

    nentries = io.get_n_entries()

    for ientry in range(nentries):
        io.read_entry(ientry)

        # Event Image
        ev_img = io.get_data(larcv.kProductImage2D, "wire")
        img_v = ev_img.Image2DArray()
        img_np_v = [larcv.as_ndarray(img_v.at(p)) for p in range(3)]

        # ChStatus
        ev_chstatus = io.get_data(larcv.kProductChStatus, "wire")
        label_v = ubbadch.makeBadChImage(
            4, 3, 2400,