Ejemplo n.º 1
0
def main(opts):

    # Set the ROOTeError verbosity
    ROOT.gErrorIgnoreLevel = 3000  # kUnset=-1, kPrint=0, kInfo=1000, kWarning=2000, kError=3000, kBreak=4000

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    style.setGridX(opts.gridX)
    style.setGridY(opts.gridY)
    style.setOptStat(False)

    # Obtain dsetMgrCreator and register it to module selector
    dsetMgrCreator = dataset.readFromMulticrabCfg(directory=opts.mcrab)

    # Setup & configure the dataset manager
    datasetsMgr = GetDatasetsFromDir(opts)
    datasetsMgr.updateNAllEventsToPUWeighted()

    if opts.verbose:
        datasetsMgr.PrintCrossSections()
        datasetsMgr.PrintInfo()

    # Setup & configure the dataset manager (no collision data => not needed)
    if 0:
        datasetsMgr.loadLuminosities()
        datasetsMgr.updateNAllEventsToPUWeighted()

    # Print information
    if opts.verbose:
        datasetsMgr.PrintCrossSections()
        # datasetsMgr.PrintLuminosities()

    # Print dataset information (before merge)
    datasetsMgr.PrintInfo()

    # Merge histograms (see NtupleAnalysis/python/tools/plots.py)
    plots.mergeRenameReorderForDataMC(datasetsMgr)

    # Get Luminosity
    if 0:
        intLumi = datasetsMgr.getDataset("Data").getLuminosity()

    # Apply new dataset order?
    newOrder = ReorderDatasets(datasetsMgr.getAllDatasetNames())
    datasetsMgr.selectAndReorder(newOrder)

    # Print dataset information (after merge)
    if 0:
        datasetsMgr.PrintInfo()  #Requires python 2.7.6 or 2.6.6

    # Plot Histograms
    histoList = datasetsMgr.getDataset(
        datasetsMgr.getAllDatasetNames()[0]).getDirectoryContent(opts.folder)
    histoPaths = [os.path.join(opts.folder, h) for h in histoList]
    histoType = type(
        datasetsMgr.getDataset(datasetsMgr.getAllDatasetNames()
                               [0]).getDatasetRootHisto(h).getHistogram())
    plotCount = 0
    skipList = [
        "L1TkTau_MatchTk_d0", "L1TkTau_MatchTk_d0Abs", "L1TkTau_SigTks_d0",
        "L1TkTau_SigTks_d0Abs", "L1TkTau_SigTks_d0Sig",
        "L1TkTau_SigTks_d0SigAbs", "L1TkTau_IsoTks_d0", "L1TkTau_IsoTks_d0Abs",
        "L1TkTau_IsoTks_d0Sig", "L1TkTau_IsoTks_d0SigAbs",
        "L1TkTau_ResolutionCaloEt_F", "L1TkTau_ResolutionCaloEta_F",
        "L1TkTau_ResolutionCaloPhi_F", "L1TkIsoTau_ResolutionCaloEt_F",
        "L1TkIsoTau_ResolutionCaloEta_F", "L1TkIsoTau_ResolutionCaloPhi_F",
        "DiTau_Rate_Calo_F", "DiTau_Rate_Tk_F", "DiTau_Rate_VtxIso_F",
        "DiTau_Rate_RelIso_F", "Calo_Rate_F", "Tk_Rate_F", "VtxIso_Rate_F",
        "RelIso_Rate_F"
    ]

    # For-loop: All histos in opts.folder
    for i, h in enumerate(histoPaths, 1):

        # Obsolete quantity
        if h in skipList:
            continue

        histoType = str(
            type(
                datasetsMgr.getDataset(
                    datasetsMgr.getAllDatasetNames()[0]).getDatasetRootHisto(
                        h).getHistogram()))
        if "TH1" not in histoType:
            continue

        aux.PrintFlushed(h, plotCount == 0)
        plotCount += 1
        PlotHisto(datasetsMgr, h)

    print
    Print(
        "All plots saved under directory %s" %
        (ShellStyles.NoteStyle() + aux.convertToURL(opts.saveDir, opts.url) +
         ShellStyles.NormalStyle()), True)
    return
Ejemplo n.º 2
0
def main(opts):

    # Set the ROOTeError verbosity
    ROOT.gErrorIgnoreLevel = 3000  # kUnset=-1, kPrint=0, kInfo=1000, kWarning=2000, kError=3000, kBreak=4000

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    style.setGridX(opts.gridX)
    style.setGridY(opts.gridY)
    style.setOptStat(False)

    # Obtain dsetMgrCreator and register it to module selector
    dsetMgrCreator = dataset.readFromMulticrabCfg(directory=opts.mcrab)

    # Setup & configure the dataset manager
    datasetsMgr = GetDatasetsFromDir(opts)
    datasetsMgr.updateNAllEventsToPUWeighted()

    if opts.verbose:
        datasetsMgr.PrintCrossSections()
        datasetsMgr.PrintInfo()

    # Setup & configure the dataset manager (no collision data => not needed)
    if 0:
        datasetsMgr.loadLuminosities()
        datasetsMgr.updateNAllEventsToPUWeighted()

    # Print information
    if opts.verbose:
        datasetsMgr.PrintCrossSections()
        # datasetsMgr.PrintLuminosities()

    # Print dataset information (before merge)
    datasetsMgr.PrintInfo()

    # Merge histograms (see NtupleAnalysis/python/tools/plots.py)
    plots.mergeRenameReorderForDataMC(datasetsMgr)

    # Get Luminosity
    if 0:
        intLumi = datasetsMgr.getDataset("Data").getLuminosity()

    # Apply new dataset order?
    newOrder = ReorderDatasets(datasetsMgr.getAllDatasetNames(),
                               bReverse=False)
    datasetsMgr.selectAndReorder(newOrder)

    # Print dataset information (after merge)
    if 0:
        datasetsMgr.PrintInfo()  #Requires python 2.7.6 or 2.6.6

    # Plot Histograms
    histoList = datasetsMgr.getDataset(
        datasetsMgr.getAllDatasetNames()[0]).getDirectoryContent(opts.folder)
    histoPaths = [os.path.join(opts.folder, h) for h in histoList]
    histoType = type(
        datasetsMgr.getDataset(datasetsMgr.getAllDatasetNames()
                               [0]).getDatasetRootHisto(h).getHistogram())
    plotCount = 0
    inList = ["ETResolution"]

    # For-loop: All# histos in opts.folder
    for i, h in enumerate(histoPaths, 1):

        # Only do Et (don't expect dependence on PU for eta, phi
        if "etresolution" not in h.lower():
            continue

        # Forwards region not yet available for Calos
        if "_F" in h:
            continue

        bSkip = True
        for s in inList:
            bSkip = False
        if bSkip:
            continue

        histoType = str(
            type(
                datasetsMgr.getDataset(
                    datasetsMgr.getAllDatasetNames()[0]).getDatasetRootHisto(
                        h).getHistogram()))
        if "TH1" not in histoType:
            continue

        aux.PrintFlushed(h, plotCount == 0)
        plotCount += 1

        PlotHisto(datasetsMgr, h)

    print
    Print(
        "All plots saved under directory %s" %
        (ShellStyles.NoteStyle() + aux.convertToURL(opts.saveDir, opts.url) +
         ShellStyles.NormalStyle()), True)
    return
Ejemplo n.º 3
0
def main(opts):

    # Set the ROOTeError verbosity
    ROOT.gErrorIgnoreLevel = 3000  # kUnset=-1, kPrint=0, kInfo=1000, kWarning=2000, kError=3000, kBreak=4000

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    style.setGridX(opts.gridX)
    style.setGridY(opts.gridY)
    style.setOptStat(False)

    # Obtain dsetMgrCreator and register it to module selector
    dsetMgrCreator = dataset.readFromMulticrabCfg(directory=opts.mcrab)

    # Setup & configure the dataset manager
    datasetsMgr = GetDatasetsFromDir(opts)
    datasetsMgr.updateNAllEventsToPUWeighted()

    if opts.verbose:
        datasetsMgr.PrintCrossSections()
        datasetsMgr.PrintInfo()

    # Setup & configure the dataset manager (no collision data => not needed)
    if 0:
        datasetsMgr.loadLuminosities()
        datasetsMgr.updateNAllEventsToPUWeighted()

    # Print information
    if opts.verbose:
        datasetsMgr.PrintCrossSections()
        # datasetsMgr.PrintLuminosities()

    # Print dataset information (before merge)
    datasetsMgr.PrintInfo()

    # Merge histograms (see NtupleAnalysis/python/tools/plots.py)
    plots.mergeRenameReorderForDataMC(datasetsMgr)

    # Get Luminosity
    if 0:
        intLumi = datasetsMgr.getDataset("Data").getLuminosity()

    # Print dataset information (after merge)
    if 0:
        datasetsMgr.PrintInfo()  #Requires python 2.7.6 or 2.6.6

    # Sanity check
    nDatasets = len(datasetsMgr.getAllDatasetNames())
    if (nDatasets) > 1:
        raise Exception(
            "More than 1 datasets found! Please choose only 1 dataset (-i \"regex\") and retry"
        )

    # Plot Histograms
    histoList = datasetsMgr.getDataset(
        datasetsMgr.getAllDatasetNames()[0]).getDirectoryContent(opts.folder)
    histoPaths = [os.path.join(opts.folder, h) for h in histoList]
    histoType = type(
        datasetsMgr.getDataset(datasetsMgr.getAllDatasetNames()
                               [0]).getDatasetRootHisto(h).getHistogram())
    plotCount = 0

    # For-loop: All# histos in opts.folder
    for i, h in enumerate(histoPaths, 1):

        histoType = str(
            type(
                datasetsMgr.getDataset(
                    datasetsMgr.getAllDatasetNames()[0]).getDatasetRootHisto(
                        h).getHistogram()))
        if "TH1" in histoType or "TDirectoryFile" in histoType:
            continue
        else:
            # print "histoType = ", histoType
            pass

        if "GenP" in h:
            continue

        aux.PrintFlushed(h, plotCount == 0)
        plotCount += 1

        PlotHisto(datasetsMgr, h, histoType)

    print
    Print(
        "All plots saved under directory %s" %
        (ShellStyles.NoteStyle() + aux.convertToURL(opts.saveDir, opts.url) +
         ShellStyles.NormalStyle()), True)
    return