Пример #1
0
def splitTree():

    dsNum, subNum = 0, 25

    inPath = "/global/homes/w/wisecg/project/waveskim/waveSkimDS%d_%d.root" % (dsNum, subNum)
    outPath = "./cutSkimDS%d_%d.root" % (dsNum, subNum)

    inFile = TFile(inPath)
    bigTree = inFile.Get("skimTree")

    theCut = inFile.Get("theCut").GetTitle()

    bigTree.Draw(">>elist",theCut,"entrylist")
    elist = gDirectory.Get("elist")
    bigTree.SetEntryList(elist)
    nList = elist.GetN()

    outFile = TFile(outPath,"RECREATE")

    lilTree = TTree()
    lilTree.SetMaxTreeSize(150000000)
    lilTree = bigTree.CopyTree("")

    lilTree.Write("",TObject.kOverwrite)

    thisCut = TNamed("theCut",theCut)
    thisCut.Write()
Пример #2
0
def splitFile(inPath, outPath):
    """ ./job-panda.py -splitf [inPath] [outPath]
    Used by specialSplit. """
    from ROOT import TFile, TTree, TObject
    inFile = TFile(inPath)
    bigTree = inFile.Get("skimTree")
    outFile = TFile(outPath, "RECREATE")
    lilTree = TTree()
    lilTree.SetMaxTreeSize(30000000)  # 30MB
    lilTree = bigTree.CopyTree("")
    lilTree.Write("", TObject.kOverwrite)
Пример #3
0
def splitTree(dsNum, subNum=None, runNum=None):
    """ ./job-panda.py -split (-sub dsNum subNum) (-run dsNum runNum)

        Split a SINGLE waveSkim file into small (~50MB) files to speed up LAT parallel processing.
        Can call 'batchSplit' instead to submit each run in the list as a job, splitting the files in parallel.
        NOTE: The cut written into the first file is NOT copied into the additional files
              (I couldn't get it to work within this function -- kept getting "file not closed" errors.)
              To clean up, do that with the 'writeCut' function below, potentially AFTER a big parallel job.
    """
    from ROOT import TFile, TTree, gDirectory, TEntryList, TNamed, TObject, gROOT

    print("Splitting tree.  dsNum:", dsNum, "subNum:", subNum, "runNum:",
          runNum)

    # Set input and output paths.  Clear out any files from a previous
    # try before you attempt a copy (avoid the double underscore)
    inPath, outPath = "", ""
    if runNum == None:
        # bg mode
        inPath = "%s/waveSkimDS%d_%d.root" % (dsi.waveDir, dsNum, subNum)
        outPath = "%s/splitSkimDS%d_%d.root" % (dsi.splitDir, dsNum, subNum)
        fileList = sorted(
            glob.glob("%s/splitSkimDS%d_%d*.root" %
                      (dsi.splitDir, dsNum, subNum)))
        for f in fileList:
            os.remove(f)
    elif subNum == None:
        # cal mode
        inPath = "%s/waveSkimDS%d_run%d.root" % (dsi.calWaveDir, dsNum, runNum)
        outPath = "%s/splitSkimDS%d_run%d.root" % (dsi.calSplitDir, dsNum,
                                                   runNum)
        fileList = sorted(
            glob.glob("%s/splitSkimDS%d_run%d*.root" %
                      (dsi.calSplitDir, dsNum, runNum)))
        for f in fileList:
            os.remove(f)

    inFile = TFile(inPath)
    bigTree = inFile.Get("skimTree")
    theCut = inFile.Get("theCut").GetTitle()
    bigTree.Draw(">>elist", theCut, "entrylist")
    elist = gDirectory.Get("elist")
    bigTree.SetEntryList(elist)
    nList = elist.GetN()

    outFile = TFile(outPath, "RECREATE")
    lilTree = TTree()
    lilTree.SetMaxTreeSize(50000000)  # 50 MB
    thisCut = TNamed("theCut", theCut)
    thisCut.Write("", TObject.kOverwrite)
    lilTree = bigTree.CopyTree(
        "")  # this does NOT write the cut into the extra files
    lilTree.Write("", TObject.kOverwrite)