Esempio n. 1
0
def main(opts):

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

    optModes = [""]
    if opts.optMode != None:
        optModes = [opts.optMode]

    # For-loop: All opt Mode
    for opt in optModes:
        opts.optMode = opt

        # Setup & configure the dataset manager
        datasetsMgr = GetDatasetsFromDir(opts)
        datasetsMgr.updateNAllEventsToPUWeighted()
        if 0:
            datasetsMgr.loadLuminosities()  # from lumi.json

        # Custom filtering of datasets
        datasetsToRemove = []
        # For-loop: All dsets to be removed
        for i, d in enumerate(datasetsToRemove, 0):
            msg = "Removing dataset %s" % d
            Print(ShellStyles.WarningLabel() + msg + ShellStyles.NormalStyle(),
                  i == 0)
            datasetsMgr.remove(
                filter(lambda name: d in name,
                       datasetsMgr.getAllDatasetNames()))

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

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

        # Define signal and background datasets names
        dsets_signal = []
        dsets_minBias = []
        for d in datasetsMgr.getAllDatasetNames():
            if "SingleNeutrino" in d:
                dsets_minBias.append(d)
            else:
                dsets_signal.append(d)

        # ROC curve ingredients (histograms)
        effLists = [[
            "Calo_Eff", "Tk_Eff", "VtxIso_Eff", "RelIso_Eff", "Iso_Eff"
        ],
                    [
                        "DiTau_Eff_Calo", "DiTau_Eff_Tk", "DiTau_Eff_VtxIso",
                        "DiTau_Eff_RelIso", "DiTau_Eff_Iso"
                    ]]

        rateLists = [
            ["Calo_Rate", "Tk_Rate", "VtxIso_Rate", "RelIso_Rate", "Iso_Rate"],
            [
                "DiTau_Rate_Calo", "DiTau_Rate_Tk", "DiTau_Rate_VtxIso",
                "DiTau_Rate_RelIso", "DiTau_Rate_Iso"
            ]
        ]

        turnOnLists = [[
            "Calo_TurnOn25", "Tk_TurnOn25", "RelIso_TurnOn25",
            "VtxIso_TurnOn25", "Iso_TurnOn25"
        ],
                       [
                           "Calo_TurnOn50", "Tk_TurnOn50", "RelIso_TurnOn50",
                           "VtxIso_TurnOn50", "Iso_TurnOn50"
                       ]]

        # For-loop: All background histos (min bias)
        for i, b in enumerate(dsets_minBias, 1):
            bPU = b.split("PU")[1]

            # Create rate plots (SingleTau, DiTau)
            PlotRate(datasetsMgr, rateLists[0], b, bPU)
            PlotRate(datasetsMgr, rateLists[1], b, bPU)

            # For-loop: All signal histos
            for j, s in enumerate(dsets_signal, 1):
                sPU = s.split("PU")[1]

                # Create rate plots (SingleTau, DiTau)
                PlotEfficiency(datasetsMgr, effLists[0], s, sPU)
                PlotEfficiency(datasetsMgr, effLists[1], s, sPU)

                if bPU != sPU:
                    continue
                else:
                    PU = sPU

                # For-loop: All triggers (Calo, Calo+Tk, Calo+VtxIso)
                for k in range(0, len(effLists)):
                    eff = effLists[k]
                    rate = rateLists[k]
                    Verbose("Bkg = %s, Signal = %s" % (b, s), False)
                    PlotRateVsEff(datasetsMgr, eff, rate, s, b, PU)

        # For-loop: All signal histos
        for i, s in enumerate(dsets_signal, 1):
            PU = s.split("PU")[1]

            # Create rate plots (SingleTau, DiTau)
            PlotTurnOns(datasetsMgr, turnOnLists[0], s, PU)
            PlotTurnOns(datasetsMgr, turnOnLists[1], s, PU)
        print

    Print(
        "All plots saved under directory %s" %
        (ShellStyles.NoteStyle() + aux.convertToURL(opts.saveDir, opts.url) +
         ShellStyles.NormalStyle()), True)
    return
Esempio n. 2
0
def main(opts):
    
    # Apply TDR style
    style = tdrstyle.TDRStyle()
    style.setOptStat(False)
    style.setGridX(opts.gridX)
    style.setGridY(opts.gridY)

    optModes = [""]
    if opts.optMode != None:
        optModes = [opts.optMode]
        
    # For-loop: All opt Mode
    for opt in optModes:
        opts.optMode = opt

        # Setup & configure the dataset manager 
        datasetsMgr = GetDatasetsFromDir(opts)
        datasetsMgr.updateNAllEventsToPUWeighted()
        if 0:
            datasetsMgr.loadLuminosities() # from lumi.json

        # Custom filtering of datasets 
        datasetsToRemove = []
        # For-loop: All dsets to be removed
        for i, d in enumerate(datasetsToRemove, 0):
            msg = "Removing dataset %s" % d
            Print(ShellStyles.WarningLabel() + msg + ShellStyles.NormalStyle(), i==0)
            datasetsMgr.remove(filter(lambda name: d in name, datasetsMgr.getAllDatasetNames()))        

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

        # Print dataset information
        datasetsMgr.PrintInfo()
        if opts.verbose:
            datasetsMgr.PrintCrossSections()
 
        # Define signal and background datasets names
        dsets_signal  = []
        dsets_minBias = []
        for d in datasetsMgr.getAllDatasetNames():
            if "SingleNeutrino" in d:
                dsets_minBias.append(d)
            else:
                dsets_signal.append(d)

        # ROC curve ingredients (histograms)
        resList = [
            ["Calo_ResolutionEt" , "Calo_ResolutionEt_1pr" , "Calo_ResolutionEt_3pr" , "Calo_ResolutionEt_withNeutrals" , "Calo_ResolutionEt_noNeutrals" ], 
            ["Calo_ResolutionEta", "Calo_ResolutionEta_1pr", "Calo_ResolutionEta_3pr", "Calo_ResolutionEta_withNeutrals", "Calo_ResolutionEta_noNeutrals"], 
            ["Calo_ResolutionPhi", "Calo_ResolutionPhi_1pr", "Calo_ResolutionPhi_3pr", "Calo_ResolutionPhi_withNeutrals", "Calo_ResolutionPhi_noNeutrals"],
            ["Calo_ResolutionEt" , "Calo_ResolutionEt_C"   , "Calo_ResolutionEt_I"], #  , "Calo_ResolutionEt_F" ],
            ["Calo_ResolutionEta", "Calo_ResolutionEta_C"  , "Calo_ResolutionEta_I"],#  , "Calo_ResolutionEta_F"],
            ["Calo_ResolutionPhi", "Calo_ResolutionPhi_C"  , "Calo_ResolutionPhi_I"],#  , "CaloIso_ResolutionPhi_F"],
            ]
                       
    
        # For-loop: All signal histos
        for i, s in enumerate(dsets_signal, 1):
            PU = s.split("PU")[1]
            
            # By decay mode
            PlotHistos(datasetsMgr, resList[0], s, PU, "ResolutionEt_%s_all" % (s) )
            PlotHistos(datasetsMgr, resList[1], s, PU, "ResolutionEta_%s_all" % (s) )
            PlotHistos(datasetsMgr, resList[2], s, PU, "ResolutionPhi_%s_all" % (s) )
            
            # By eta region (central, intermediate, forward)
            PlotHistos(datasetsMgr, resList[3], s, PU, "ResolutionEt_%s_cif"  % (s) )
            PlotHistos(datasetsMgr, resList[4], s, PU, "ResolutionEta_%s_cif" % (s) )
            PlotHistos(datasetsMgr, resList[5], s, PU, "ResolutionPhi_%s_cif" % (s) )
        print

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

    #optModes = ["", "OptChiSqrCutValue50", "OptChiSqrCutValue100"]
    optModes = [""]

    if opts.optMode != None:
        optModes = [opts.optMode]
        
    # For-loop: All opt Mode
    for opt in optModes:
        opts.optMode = opt

        # Setup & configure the dataset manager 
        datasetsMgr = GetDatasetsFromDir(opts)
        datasetsMgr.updateNAllEventsToPUWeighted() #marina
        if 0:
            datasetsMgr.loadLuminosities() # from lumi.json

        # Set/Overwrite cross-sections
        datasetsToRemove = []
        for d in datasetsMgr.getAllDatasets():
            datasetsMgr.getDataset(d.getName()).setCrossSection(1.0)

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

        # Custom Filtering of datasets 
        for i, d in enumerate(datasetsToRemove, 0):
            msg = "Removing dataset %s" % d
            Print(ShellStyles.WarningLabel() + msg + ShellStyles.NormalStyle(), i==0)
            datasetsMgr.remove(filter(lambda name: d in name, datasetsMgr.getAllDatasetNames()))
        #if opts.verbose:
            #datasetsMgr.PrintInfo()

        # Merge histograms (see NtupleAnalysis/python/tools/plots.py) 
        plots.mergeRenameReorderForDataMC(datasetsMgr) 
        
        # Get Luminosity
        if 0:
            intLumi = datasetsMgr.getDataset("Data").getLuminosity()

        # Re-order datasets (different for inverted than default=baseline)
        newOrder = []
        # For-loop: All MC datasets
        for d in datasetsMgr.getMCDatasets():
            newOrder.append(d.getName())
            
        # Apply new dataset order!
        datasetsMgr.selectAndReorder(newOrder)
        
        # Print dataset information
        #datasetsMgr.PrintInfo()
        
        # Apply TDR style
        style = tdrstyle.TDRStyle()
        #style.setOptStat(True)
        style.setGridX(opts.gridX)
        style.setGridY(opts.gridY)

        # Plot Histograms
        folder     = "" #opts.folder
        histoList  = datasetsMgr.getDataset(datasetsMgr.getAllDatasetNames()[0]).getDirectoryContent(folder)
        histoPaths = [os.path.join(folder, h) for h in histoList]
        histoType  = type(datasetsMgr.getDataset(datasetsMgr.getAllDatasetNames()[0]).getDatasetRootHisto(h).getHistogram())
        for i, h in enumerate(histoPaths, 1):
            histoType  = str(type(datasetsMgr.getDataset(datasetsMgr.getAllDatasetNames()[0]).getDatasetRootHisto(h).getHistogram()))
            if "TH2" not in histoType:
                continue
            PlotHistograms(datasetsMgr, h)

    return
Esempio n. 4
0
def main(opts):

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

    optModes = [""]
    if opts.optMode != None:
        optModes = [opts.optMode]

    # For-loop: All opt Mode
    for opt in optModes:
        opts.optMode = opt

        # Setup & configure the dataset manager
        datasetsMgr = GetDatasetsFromDir(opts)
        datasetsMgr.updateNAllEventsToPUWeighted()
        if 0:
            datasetsMgr.loadLuminosities()  # from lumi.json

        # Custom filtering of datasets
        datasetsToRemove = []
        # For-loop: All dsets to be removed
        for i, d in enumerate(datasetsToRemove, 0):
            msg = "Removing dataset %s" % d
            Print(ShellStyles.WarningLabel() + msg + ShellStyles.NormalStyle(),
                  i == 0)
            datasetsMgr.remove(
                filter(lambda name: d in name,
                       datasetsMgr.getAllDatasetNames()))

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

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

        # Define signal and background datasets names
        dsets_signal = []
        dsets_minBias = []
        for d in datasetsMgr.getAllDatasetNames():
            if "SingleNeutrino" in d:
                dsets_minBias.append(d)
            else:
                dsets_signal.append(d)

        # ROC curve ingredients (histograms)
        effLists = [[
            "Tk_Eff", "RelIso_Eff", "VtxIso_Eff", "VtxIsoLoose_Eff",
            "VtxIsoTight_Eff", "RelIsoLoose_Eff", "RelIsoTight_Eff"
        ],
                    [
                        "DiTau_Eff_Tk",
                        "DiTau_Eff_RelIso",
                        "DiTau_Eff_VtxIso",
                        "DiTau_Eff_VtxIsoLoose",
                        "DiTau_Eff_VtxIsoTight",
                        "DiTau_Eff_RelIsoLoose",
                        "DiTau_Eff_RelIsoTight",
                    ]]

        rateLists = [[
            "Tk_Rate", "RelIso_Rate", "VtxIso_Rate", "VtxIsoLoose_Rate",
            "VtxIsoTight_Rate", "RelIsoLoose_Rate", "RelIsoTight_Rate"
        ],
                     [
                         "DiTau_Rate_Tk", "DiTau_Rate_RelIso",
                         "DiTau_Rate_VtxIso", "DiTau_Rate_VtxIsoLoose",
                         "DiTau_Rate_VtxIsoTight", "DiTau_Rate_RelIsoLoose",
                         "DiTau_Rate_RelIsoTight"
                     ]]

        turnOnLists = [
            [
                "Tk_TurnOn25", "RelIso_TurnOn25", "VtxIso_TurnOn25"
            ],  # "VtxIsoLoose_TurnOn25", "VtxIsoTight_TurnOn25", "RelIsoLoose_TurnOn25", "RelIsoTight_TurnOn25"], 
            ["Tk_TurnOn50", "RelIso_TurnOn50", "VtxIso_TurnOn50"]
        ]  #, "VtxIsoLoose_TurnOn50", "VtxIsoTight_TurnOn50", "RelIsoLoose_TurnOn50", "RelIsoTight_TurnOn50"]]

        turnOnLists_noNeutrals = [[
            "Tk_TurnOn25_noNeutrals", "RelIso_TurnOn25_noNeutrals",
            "VtxIso_TurnOn25_noNeutrals"
        ],
                                  [
                                      "Tk_TurnOn50_noNeutrals",
                                      "RelIso_TurnOn50_noNeutrals",
                                      "VtxIso_TurnOn50_noNeutrals"
                                  ]]

        turnOnLists_withNeutrals = [[
            "Tk_TurnOn25_withNeutrals", "RelIso_TurnOn25_withNeutrals",
            "VtxIso_TurnOn25_withNeutrals"
        ],
                                    [
                                        "Tk_TurnOn50_withNeutrals",
                                        "RelIso_TurnOn50_withNeutrals",
                                        "VtxIso_TurnOn50_withNeutrals"
                                    ]]

        turnOnLists_1pr = [[
            "Tk_TurnOn25_1pr", "RelIso_TurnOn25_1pr", "VtxIso_TurnOn25_1pr"
        ], ["Tk_TurnOn50_1pr", "RelIso_TurnOn50_1pr", "VtxIso_TurnOn50_1pr"]]

        turnOnLists_3pr = [[
            "Tk_TurnOn25_3pr", "RelIso_TurnOn25_3pr", "VtxIso_TurnOn25_3pr"
        ], ["Tk_TurnOn50_3pr", "RelIso_TurnOn50_3pr", "VtxIso_TurnOn50_3pr"]]

        turnOnLists_all = [[
            "VtxIso_TurnOn25", "VtxIso_TurnOn25_1pr", "VtxIso_TurnOn25_3pr",
            "VtxIso_TurnOn25_withNeutrals", "VtxIso_TurnOn25_noNeutrals"
        ],
                           [
                               "VtxIso_TurnOn50", "VtxIso_TurnOn50_1pr",
                               "VtxIso_TurnOn50_3pr",
                               "VtxIso_TurnOn50_withNeutrals",
                               "VtxIso_TurnOn50_noNeutrals"
                           ]]

        # For-loop: All background histos (min bias)
        for i, b in enumerate(dsets_minBias, 1):
            bPU = b.split("PU")[1]

            # Create rate plots (SingleTau, DiTau)
            if 1:
                opts.saveDir = aux.getSaveDirPath(opts.mcrab,
                                                  prefix="hltaus/",
                                                  postfix="Rates")
                PlotRate(datasetsMgr, rateLists[0], b, bPU, "SingleTau")
                PlotRate(datasetsMgr, rateLists[1], b, bPU, "DiTau")

            # For-loop: All signal histos
            for j, s in enumerate(dsets_signal, 1):
                sPU = s.split("PU")[1]

                # Create rate plots (SingleTau, DiTau)
                if i == 1:  # (since inside minBias loop)
                    opts.saveDir = aux.getSaveDirPath(opts.mcrab,
                                                      prefix="hltaus/",
                                                      postfix="Efficiencies")
                    PlotEfficiency(datasetsMgr, effLists[0], s, sPU,
                                   "SingleTau")
                    PlotEfficiency(datasetsMgr, effLists[1], s, sPU, "DiTau")

                # Skip non-matching signal and bkg PU pairs?
                if sPU != bPU and sPU != "":
                    continue
                else:
                    if sPU == "":
                        sPU = "0"  #rename before saving

                # For-loop: All triggers
                for k in range(0, len(effLists)):
                    eff = effLists[k]
                    rate = rateLists[k]
                    Verbose("Bkg = %s, Signal = %s" % (b, s), False)
                    if 1:
                        opts.saveDir = aux.getSaveDirPath(opts.mcrab,
                                                          prefix="hltaus/",
                                                          postfix="ROC")
                        PlotRateVsEff(datasetsMgr, eff, rate, s, b, sPU, bPU)

        # For-loop: All signal histos
        for i, s in enumerate(dsets_signal, 1):
            PU = s.split("PU")[1]

            # Create rate plots (SingleTau, DiTau)
            if 1:
                opts.saveDir = aux.getSaveDirPath(opts.mcrab,
                                                  prefix="hltaus/",
                                                  postfix="TurnOns")

                PlotTurnOns(datasetsMgr, turnOnLists[0], s, PU,
                            "TurnOns_25GeV_%s_Inclusive" % (s))
                PlotTurnOns(datasetsMgr, turnOnLists[1], s, PU,
                            "TurnOns_50GeV_%s_Inclusive" % (s))

                PlotTurnOns(datasetsMgr, turnOnLists_noNeutrals[0], s, PU,
                            "TurnOns_25GeV_%s_noNeutrals" % (s))
                PlotTurnOns(datasetsMgr, turnOnLists_noNeutrals[1], s, PU,
                            "TurnOns_50GeV_%s_noNeutrals" % (s))

                PlotTurnOns(datasetsMgr, turnOnLists_withNeutrals[0], s, PU,
                            "TurnOns_25GeV_%s_withNeutrals" % (s))
                PlotTurnOns(datasetsMgr, turnOnLists_withNeutrals[1], s, PU,
                            "TurnOns_50GeV_%s_withNeutrals" % (s))

                PlotTurnOns(datasetsMgr, turnOnLists_1pr[0], s, PU,
                            "TurnOns_25GeV_%s_1pr" % (s))
                PlotTurnOns(datasetsMgr, turnOnLists_1pr[1], s, PU,
                            "TurnOns_50GeV_%s_1pr" % (s))

                PlotTurnOns(datasetsMgr, turnOnLists_3pr[0], s, PU,
                            "TurnOns_25GeV_%s_3pr" % (s))
                PlotTurnOns(datasetsMgr, turnOnLists_3pr[1], s, PU,
                            "TurnOns_50GeV_%s_3pr" % (s))

                PlotTurnOns(datasetsMgr, turnOnLists_all[0], s, PU,
                            "TurnOns_25GeV_%s_VtxIso_allModes" % (s))
                PlotTurnOns(datasetsMgr, turnOnLists_all[1], s, PU,
                            "TurnOns_50GeV_%s_VtxIso_allModes" % (s))
        print

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

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

    optModes = [""]
    if opts.optMode != None:
        optModes = [opts.optMode]

    # For-loop: All opt Mode
    for opt in optModes:
        opts.optMode = opt

        # Setup & configure the dataset manager
        datasetsMgr = GetDatasetsFromDir(opts)
        datasetsMgr.updateNAllEventsToPUWeighted()
        if 0:
            datasetsMgr.loadLuminosities()  # from lumi.json

        # Custom filtering of datasets
        datasetsToRemove = []
        # For-loop: All dsets to be removed
        for i, d in enumerate(datasetsToRemove, 0):
            msg = "Removing dataset %s" % d
            Print(ShellStyles.WarningLabel() + msg + ShellStyles.NormalStyle(),
                  i == 0)
            datasetsMgr.remove(
                filter(lambda name: d in name,
                       datasetsMgr.getAllDatasetNames()))

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

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

        # Define signal and background datasets names
        dsets_signal = []
        dsets_minBias = []
        for d in datasetsMgr.getAllDatasetNames():
            if "SingleNeutrino" in d:
                dsets_minBias.append(d)
            else:
                dsets_signal.append(d)

        # ROC curve ingredients (histograms)
        resList = [
            [
                "TkEG_EtResolution", "TkEG_EtResolution_1pr",
                "TkEG_EtResolution_3pr", "TkEG_EtResolution_withNeutrals",
                "TkEG_EtResolution_noNeutrals"
            ],
            [
                "TkEG_EtaResolution", "TkEG_EtaResolution_1pr",
                "TkEG_EtaResolution_3pr", "TkEG_EtaResolution_withNeutrals",
                "TkEG_EtaResolution_noNeutrals"
            ],
            [
                "TkEG_PhiResolution", "TkEG_PhiResolution_1pr",
                "TkEG_PhiResolution_3pr", "TkEG_PhiResolution_withNeutrals",
                "TkEG_PhiResolution_noNeutrals"
            ],
            [
                "TkEG_EtResolution", "TkEG_EtResolution_C",
                "TkEG_EtResolution_I", "TkEG_EtResolution_F"
            ],
            [
                "TkEG_EtaResolution", "TkEG_EtaResolution_C",
                "TkEG_EtaResolution_I", "TkEG_EtaResolution_F"
            ],
            [
                "TkEG_PhiResolution", "TkEG_PhiResolution_C",
                "TkEG_PhiResolution_I", "TkEG_PhiResolution_F"
            ],
            [
                "TkEG_EtResolution_F", "TkEG_EtResolution_1pr_F",
                "TkEG_EtResolution_3pr_F", "TkEG_EtResolution_withNeutrals_F",
                "TkEG_EtResolution_noNeutrals_F"
            ],
            [
                "TkEG_EtaResolution_F", "TkEG_EtaResolution_1pr_F",
                "TkEG_EtaResolution_3pr_F",
                "TkEG_EtaResolution_withNeutrals_F",
                "TkEG_EtaResolution_noNeutrals_F"
            ],
            [
                "TkEG_PhiResolution_F", "TkEG_PhiResolution_1pr_F",
                "TkEG_PhiResolution_3pr_F",
                "TkEG_PhiResolution_withNeutrals_F",
                "TkEG_PhiResolution_noNeutrals_F"
            ],
            [
                "TkEG_EtResolution_F_withEGs",
                "TkEG_EtResolution_1pr_F_withEGs",
                "TkEG_EtResolution_3pr_F_withEGs",
                "TkEG_EtResolution_withNeutrals_F_withEGs",
                "TkEG_EtResolution_noNeutrals_F_withEGs"
            ],
            [
                "TkEG_EtaResolution_F_withEGs",
                "TkEG_EtaResolution_1pr_F_withEGs",
                "TkEG_EtaResolution_3pr_F_withEGs",
                "TkEG_EtaResolution_withNeutrals_F_withEGs",
                "TkEG_EtaResolution_noNeutrals_F_withEGs"
            ],
            [
                "TkEG_PhiResolution_F_withEGs",
                "TkEG_PhiResolution_1pr_F_withEGs",
                "TkEG_PhiResolution_3pr_F_withEGs",
                "TkEG_PhiResolution_withNeutrals_F_withEGs",
                "TkEG_PhiResolution_noNeutrals_F_withEGs"
            ],
            [
                "TkEG_EtResolution_F_noEGs", "TkEG_EtResolution_1pr_F_noEGs",
                "TkEG_EtResolution_3pr_F_noEGs",
                "TkEG_EtResolution_withNeutrals_F_noEGs",
                "TkEG_EtResolution_noNeutrals_F_noEGs"
            ],
            [
                "TkEG_EtaResolution_F_noEGs", "TkEG_EtaResolution_1pr_F_noEGs",
                "TkEG_EtaResolution_3pr_F_noEGs",
                "TkEG_EtaResolution_withNeutrals_F_noEGs",
                "TkEG_EtaResolution_noNeutrals_F_noEGs"
            ],
            [
                "TkEG_PhiResolution_F_noEGs", "TkEG_PhiResolution_1pr_F_noEGs",
                "TkEG_PhiResolution_3pr_F_noEGs",
                "TkEG_PhiResolution_withNeutrals_F_noEGs",
                "TkEG_PhiResolution_noNeutrals_F_noEGs"
            ],
            [
                "TkEG_EtResolution_F_withEGs_posEta",
                "TkEG_EtResolution_1pr_F_withEGs_posEta",
                "TkEG_EtResolution_3pr_F_withEGs_posEta",
                "TkEG_EtResolution_withNeutrals_F_withEGs_posEta",
                "TkEG_EtResolution_noNeutrals_F_withEGs_posEta"
            ],
            [
                "TkEG_EtaResolution_F_withEGs_posEta",
                "TkEG_EtaResolution_1pr_F_withEGs_posEta",
                "TkEG_EtaResolution_3pr_F_withEGs_posEta",
                "TkEG_EtaResolution_withNeutrals_F_withEGs_posEta",
                "TkEG_EtaResolution_noNeutrals_F_withEGs_posEta"
            ],
            [
                "TkEG_PhiResolution_F_withEGs_posEta",
                "TkEG_PhiResolution_1pr_F_withEGs_posEta",
                "TkEG_PhiResolution_3pr_F_withEGs_posEta",
                "TkEG_PhiResolution_withNeutrals_F_withEGs_posEta",
                "TkEG_PhiResolution_noNeutrals_F_withEGs_posEta"
            ],
            [
                "TkEG_EtResolution_F_noEGs_posEta",
                "TkEG_EtResolution_1pr_F_noEGs_posEta",
                "TkEG_EtResolution_3pr_F_noEGs_posEta",
                "TkEG_EtResolution_withNeutrals_F_noEGs_posEta",
                "TkEG_EtResolution_noNeutrals_F_noEGs_posEta"
            ],
            [
                "TkEG_EtaResolution_F_noEGs_posEta",
                "TkEG_EtaResolution_1pr_F_noEGs_posEta",
                "TkEG_EtaResolution_3pr_F_noEGs_posEta",
                "TkEG_EtaResolution_withNeutrals_F_noEGs_posEta",
                "TkEG_EtaResolution_noNeutrals_F_noEGs_posEta"
            ],
            [
                "TkEG_PhiResolution_F_noEGs_posEta",
                "TkEG_PhiResolution_1pr_F_noEGs_posEta",
                "TkEG_PhiResolution_3pr_F_noEGs_posEta",
                "TkEG_PhiResolution_withNeutrals_F_noEGs_posEta",
                "TkEG_PhiResolution_noNeutrals_F_noEGs_posEta"
            ],
            [
                "TkEG_EtResolution_F_withEGs_negEta",
                "TkEG_EtResolution_1pr_F_withEGs_negEta",
                "TkEG_EtResolution_3pr_F_withEGs_negEta",
                "TkEG_EtResolution_withNeutrals_F_withEGs_negEta",
                "TkEG_EtResolution_noNeutrals_F_withEGs_negEta"
            ],
            [
                "TkEG_EtaResolution_F_withEGs_negEta",
                "TkEG_EtaResolution_1pr_F_withEGs_negEta",
                "TkEG_EtaResolution_3pr_F_withEGs_negEta",
                "TkEG_EtaResolution_withNeutrals_F_withEGs_negEta",
                "TkEG_EtaResolution_noNeutrals_F_withEGs_negEta"
            ],
            [
                "TkEG_PhiResolution_F_withEGs_negEta",
                "TkEG_PhiResolution_1pr_F_withEGs_negEta",
                "TkEG_PhiResolution_3pr_F_withEGs_negEta",
                "TkEG_PhiResolution_withNeutrals_F_withEGs_negEta",
                "TkEG_PhiResolution_noNeutrals_F_withEGs_negEta"
            ],
            [
                "TkEG_EtResolution_F_noEGs_negEta",
                "TkEG_EtResolution_1pr_F_noEGs_negEta",
                "TkEG_EtResolution_3pr_F_noEGs_negEta",
                "TkEG_EtResolution_withNeutrals_F_noEGs_negEta",
                "TkEG_EtResolution_noNeutrals_F_noEGs_negEta"
            ],
            [
                "TkEG_EtaResolution_F_noEGs_negEta",
                "TkEG_EtaResolution_1pr_F_noEGs_negEta",
                "TkEG_EtaResolution_3pr_F_noEGs_negEta",
                "TkEG_EtaResolution_withNeutrals_F_noEGs_negEta",
                "TkEG_EtaResolution_noNeutrals_F_noEGs_negEta"
            ],
            [
                "TkEG_PhiResolution_F_noEGs_negEta",
                "TkEG_PhiResolution_1pr_F_noEGs_negEta",
                "TkEG_PhiResolution_3pr_F_noEGs_negEta",
                "TkEG_PhiResolution_withNeutrals_F_noEGs_negEta",
                "TkEG_PhiResolution_noNeutrals_F_noEGs_negEta"
            ],
            [
                "TkEG_ChargedResolution", "TkEG_ChargedResolution_1pr",
                "TkEG_ChargedResolution_3pr",
                "TkEG_ChargedResolution_withNeutrals",
                "TkEG_ChargedResolution_noNeutrals"
            ],
            [
                "TkEG_NeutralsResolution", "TkEG_NeutralsResolution_1pr",
                "TkEG_NeutralsResolution_3pr",
                "TkEG_NeutralsResolution_withNeutrals",
                "TkEG_NeutralsResolution_noNeutrals"
            ],
            [
                "TkEG_EtResolution_withEGs", "TkEG_EtResolution_1pr_withEGs",
                "TkEG_EtResolution_3pr_withEGs",
                "TkEG_EtResolution_withNeutrals_withEGs",
                "TkEG_EtResolution_noNeutrals_withEGs"
            ],
            [
                "TkEG_EtResolution_noEGs", "TkEG_EtResolution_1pr_noEGs",
                "TkEG_EtResolution_3pr_noEGs",
                "TkEG_EtResolution_withNeutrals_noEGs",
                "TkEG_EtResolution_noNeutrals_noEGs"
            ],
            [
                "TkEG_EtResolution_withNeutrals",
                "TkEG_EtResolution_withNeutrals_1pr",
                "TkEG_EtResolution_withNeutrals_3pr"
            ],
            [
                "TkEG_EtResolution_withNeutrals",
                "TkEG_EtResolution_withNeutrals_1pion0",
                "TkEG_EtResolution_withNeutrals_2pion0",
                "TkEG_EtResolution_withNeutrals_3pion0"
            ],  #,"TkEG_EtResolution_withNeutrals_4pion0"],
            [
                "TkEG_EtResolution_withNeutrals_withEGs",
                "TkEG_EtResolution_withNeutrals_withEGs_0to5GeV",
                "TkEG_EtResolution_withNeutrals_withEGs_5to10GeV",
                "TkEG_EtResolution_withNeutrals_withEGs_10to15GeV",
                "TkEG_EtResolution_withNeutrals_withEGs_15to20GeV",
                "TkEG_EtResolution_withNeutrals_withEGs_20to30GeV",
                "TkEG_EtResolution_withNeutrals_withEGs_30to40GeV",
                "TkEG_EtResolution_withNeutrals_withEGs_40to50GeV"
            ]
        ]

        # For-loop: All signal histos
        for i, s in enumerate(dsets_signal, 1):
            PU = s.split("PU")[1]

            # By decay mode
            PlotHistos(datasetsMgr, resList[0], s, PU,
                       "ResolutionEt_%s_all" % (s))
            PlotHistos(datasetsMgr, resList[1], s, PU,
                       "ResolutionEta_%s_all" % (s))
            PlotHistos(datasetsMgr, resList[2], s, PU,
                       "ResolutionPhi_%s_all" % (s))

            # By eta region (central, intermediate, forward)
            PlotHistos(datasetsMgr, resList[3], s, PU,
                       "ResolutionEt_%s_cif" % (s))
            PlotHistos(datasetsMgr, resList[4], s, PU,
                       "ResolutionEta_%s_cif" % (s))
            PlotHistos(datasetsMgr, resList[5], s, PU,
                       "ResolutionPhi_%s_cif" % (s))

            PlotHistos(datasetsMgr, resList[6], s, PU,
                       "ResolutionEt_%s_all_F" % (s))
            PlotHistos(datasetsMgr, resList[7], s, PU,
                       "ResolutionEta_%s_all_F" % (s))
            PlotHistos(datasetsMgr, resList[8], s, PU,
                       "ResolutionPhi_%s_all_F" % (s))

            PlotHistos(datasetsMgr, resList[9], s, PU,
                       "ResolutionEt_%s_all_F_withEGs" % (s))
            PlotHistos(datasetsMgr, resList[10], s, PU,
                       "ResolutionEta_%s_all_F_withEGs" % (s))
            PlotHistos(datasetsMgr, resList[11], s, PU,
                       "ResolutionPhi_%s_all_F_withEGs" % (s))

            PlotHistos(datasetsMgr, resList[12], s, PU,
                       "ResolutionEt_%s_all_F_noEGs" % (s))
            PlotHistos(datasetsMgr, resList[13], s, PU,
                       "ResolutionEta_%s_all_F_noEGs" % (s))
            PlotHistos(datasetsMgr, resList[14], s, PU,
                       "ResolutionPhi_%s_all_F_noEGs" % (s))

            PlotHistos(datasetsMgr, resList[15], s, PU,
                       "ResolutionEt_%s_all_F_withEGs_posEta" % (s))
            PlotHistos(datasetsMgr, resList[16], s, PU,
                       "ResolutionEta_%s_all_F_withEGs_posEta" % (s))
            PlotHistos(datasetsMgr, resList[17], s, PU,
                       "ResolutionPhi_%s_all_F_withEGs_posEta" % (s))

            PlotHistos(datasetsMgr, resList[18], s, PU,
                       "ResolutionEt_%s_all_F_noEGs_posEta" % (s))
            PlotHistos(datasetsMgr, resList[19], s, PU,
                       "ResolutionEta_%s_all_F_noEGs_posEta" % (s))
            PlotHistos(datasetsMgr, resList[20], s, PU,
                       "ResolutionPhi_%s_all_F_noEGs_posEta" % (s))

            PlotHistos(datasetsMgr, resList[21], s, PU,
                       "ResolutionEt_%s_all_F_withEGs_negEta" % (s))
            PlotHistos(datasetsMgr, resList[22], s, PU,
                       "ResolutionEta_%s_all_F_withEGs_negEta" % (s))
            PlotHistos(datasetsMgr, resList[23], s, PU,
                       "ResolutionPhi_%s_all_F_withEGs_negEta" % (s))

            PlotHistos(datasetsMgr, resList[24], s, PU,
                       "ResolutionEt_%s_all_F_noEGs_negEta" % (s))
            PlotHistos(datasetsMgr, resList[25], s, PU,
                       "ResolutionEta_%s_all_F_noEGs_negEta" % (s))
            PlotHistos(datasetsMgr, resList[26], s, PU,
                       "ResolutionPhi_%s_all_F_noEGs_negEta" % (s))

            PlotHistos(datasetsMgr, resList[27], s, PU,
                       "ResolutionCharged_%s_all" % (s))
            PlotHistos(datasetsMgr, resList[28], s, PU,
                       "ResolutionNeutrals_%s_all" % (s))

            PlotHistos(datasetsMgr, resList[29], s, PU,
                       "ResolutionEt_%s_all_withEGs" % (s))
            PlotHistos(datasetsMgr, resList[30], s, PU,
                       "ResolutionEt_%s_all_noEGs" % (s))
            PlotHistos(datasetsMgr, resList[31], s, PU,
                       "ResolutionEt_%s_withNeutrals" % (s))
            PlotHistos(datasetsMgr, resList[32], s, PU,
                       "ResolutionEt_%s_withNeutrals_Npion0" % (s))

            PlotHistos(datasetsMgr, resList[33], s, PU,
                       "ResolutionEt_%s_withNeutrals_withEGs_etSteps" % (s))

        print

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

    optModes = [""]

    if opts.optMode != None:
        optModes = [opts.optMode]
        
    # Apply TDR style
    style = tdrstyle.TDRStyle()
    style.setOptStat(False)
    style.setGridX(opts.gridX)
    style.setGridY(opts.gridY)
    style.setLogX(opts.logX)
    style.setLogY(opts.logY)
    style.setLogZ(opts.logZ)
    #style.setWide(False, 0.15)

    # For-loop: All opt Mode
    for opt in optModes:
        opts.optMode = opt

        # Setup & configure the dataset manager 
        datasetsMgr = GetDatasetsFromDir(opts)
        datasetsMgr.updateNAllEventsToPUWeighted()
        # datasetsMgr.loadLuminosities() # from lumi.json

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

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

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

        # Custom Filtering of datasets 
        datasetsToRemove = []
        for i, d in enumerate(datasetsToRemove, 0):
            msg = "Removing dataset %s" % d
            Print(ShellStyles.WarningLabel() + msg + ShellStyles.NormalStyle(), i==0)
            datasetsMgr.remove(filter(lambda name: d in name, datasetsMgr.getAllDatasetNames()))

        if opts.verbose:
            datasetsMgr.PrintInfo()

        # Re-order datasets (different for inverted than default=baseline)
        newOrder = []
        for d in datasetsMgr.getMCDatasets():
            newOrder.append(d.getName())
            
        # Apply new dataset order!
        datasetsMgr.selectAndReorder(newOrder)
        
        # Print dataset information
        datasetsMgr.PrintInfo()        

        # Plot Histograms
        histoList  = datasetsMgr.getDataset(datasetsMgr.getAllDatasetNames()[0]).getDirectoryContent(opts.folder)
        histoPaths = [os.path.join(opts.folder, h) for h in histoList]
        
        # For-loop: All histograms in chosen folder
        counter = 0
        for i, h in enumerate(histoPaths, 1):
            histoType  = str(type(datasetsMgr.getDataset(datasetsMgr.getAllDatasetNames()[0]).getDatasetRootHisto(h).getHistogram()))
            if "TH2" not in histoType:
                continue
            if "DiTau" in h:
                continue
            if "L1TkIsoTau" in h:
                continue

            # For-loop: All datasets
            for d in datasetsMgr.getAllDatasetNames():
                counter += 1
                #if d != "SingleNeutrino_L1TPU140":
                #    continue
                #if "reliso" not in h.lower():
                #    continue
                Plot2dHistograms(datasetsMgr, d, h, counter)
    print
    Print("All plots saved under directory %s" % (ShellStyles.NoteStyle() + aux.convertToURL(opts.saveDir, opts.url) + ShellStyles.NormalStyle()), True)
    return