Пример #1
0
from eop_plotting.histogram_filling import HistogramFiller, get_p, get_bins, get_log_bins, create_selection_function, create_inverse_selection_function
from eop_plotting.eop_histograms import put_binning_vectors_in_file, create_eop_histograms
from eop_plotting.track_spectrum_plots import create_spectrum_plots

#create the functions that select tracks in the different eta bins
eta_bin_edges = [0.0, 0.2, 0.7, 1.3, 1.8, 2.5]
eta_bin_tuples = [(eta_bin_edges[i], eta_bin_edges[i + 1])
                  for i in range(0,
                                 len(eta_bin_edges) - 1)]
eta_bin_descriptions = [
    "eta_extrapol00_02", "eta_extrapol02_07", "eta_extrapol07_13",
    "eta_extrapol13_18", "eta_extapol18_25"
]
eta_bin_branches = ["trk_etaEMB2", "trk_etaEME2", "trk_phiEMB2", "trk_phiEME2"]
eta_bin_selections = [
    create_selection_function(EtaBin, eta_bin_branches, eta_bin_tuple[0],
                              eta_bin_tuple[1])
    for eta_bin_tuple in eta_bin_tuples
]
sel_Pion = create_selection_function(ParticlePDGID_ABS, ["trk_truthPdgId"],
                                     211.0)
sel_PionPos = create_selection_function(ParticlePDGID, ["trk_truthPdgId"],
                                        211.0)
sel_PionNeg = create_selection_function(ParticlePDGID, ["trk_truthPdgId"],
                                        -211.0)
sel_KaonPos = create_selection_function(ParticlePDGID, ["trk_truthPdgId"],
                                        321.0)
sel_KaonNeg = create_selection_function(ParticlePDGID, ["trk_truthPdgId"],
                                        -321.0)
sel_ProtonPos = create_selection_function(ParticlePDGID, ["trk_truthPdgId"],
                                          2212.0)
sel_ProtonNeg = create_selection_function(ParticlePDGID, ["trk_truthPdgId"],
Пример #2
0
def create_eop_histograms(hist_filler, base_selection, eta_ranges,p_bins_for_eta_range, description, do_cluster_plots=False, do_calib_hit_plots=False):
    #define a set of eta bins
    eta_count = -1
    for eta_range, p_bins in zip(eta_ranges, p_bins_for_eta_range):
        eta_count += 1
        #get the function that selects tracks in that bin
        eta_bin_selection = create_selection_function(EtaBin, ["trk_etaEMB2","trk_etaEME2","trk_phiEME2", "trk_phiEMB2"], eta_range[0], eta_range[1])

        selections = base_selection + [eta_bin_selection]

        NPtBins = len(p_bins)
        Pt_low = 0.5
        Pt_high = max(p_bins)
        ptbins = get_log_bins(Pt_low, Pt_high, NPtBins)
        eop_bins = get_bins(-1.0, +3.0, 800) # use a super fine binning

        histogram_name = "EOPProfileVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)

        from eop_plotting.variables import calc_EOP
        hist_filler.book_tprofile_fill(histogram_name,
                                                  calc_trkP,\
                                                  calc_EOP,\
                                                  selections = selections,\
                                                  bins = p_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "<E/p>",\
                                                  )

        histogram_name = "2DHist_EOPVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        hist_filler.book_2dhistogram_fill(histogram_name,
                                                  calc_trkP,\
                                                  calc_EOP,\
                                                  selections = selections,\
                                                  bins_x = p_bins,\
                                                  bins_y = eop_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "E/p",\
                                                  )
        from variables import cone_strings, total_energy_annulus_template
        from math import pi
        def annulus_area(low,high):
            return pi * ((high ** 2) - (low ** 2))
        for (low, high) in zip(cone_strings[:-1], cone_strings[1:]):
            #this function calculates the energy in a cone from low to high
            func_e = lambda x, y = low, z = high : total_energy_annulus_template(x,y,z)
            func_e.__name__ = "energy_in_cone_{}_{}".format(low, high)
            #this function calculates the energy in a cone from low to high
            func_e_area = lambda x, y = low, z = high, l=low, h=high : total_energy_annulus_template(x,y,z)/(annulus_area(float(l)/1000.0, float(h)/1000.0))
            func_e_area.__name__ = "energy_in_cone_area_{}_{}".format(low, high)
            #this function calculates the eop in a cone from low to high
            func_eop = lambda x, y = low, z = high : total_energy_annulus_template(x,y,z)/x["trk_p"]
            func_eop.__name__ = "eop_in_cone_{}_{}".format(low, high)
            #this function calculates the eop in a cone from low to high
            func_eop_area = lambda x, y = low, z = high, l=low, h=high : (total_energy_annulus_template(x,y,z)/x["trk_p"])/(annulus_area(float(l)/1000.0, float(h)/1000.0))
            func_eop_area.__name__ = "eop_in_cone_area_{}_{}".format(low, high)

            #define the calculation and the branches that we need for this
            branches = ["trk_ClusterEnergy_EM_{}".format(low), "trk_ClusterEnergy_HAD_{}".format(low)]
            branches += ["trk_ClusterEnergy_EM_{}".format(high), "trk_ClusterEnergy_HAD_{}".format(high)]
            clean_branches = []
            for b in branches:
                if "000" not in b:
                    clean_branches.append(b)
            branches = clean_branches
            from calculation import Calculation
            calc_cone_e = Calculation(func_e, branches)
            calc_cone_e_area = Calculation(func_e_area, branches)
            branches = branches + ["trk_p"]
            calc_cone_eop = Calculation(func_eop, branches)
            calc_cone_eop_area = Calculation(func_eop_area, branches)

            #book the histograms
            low_descr = float(low)/10.0
            high_descr = float(high)/10.0
            histogram_name = "EnergyAnnulusProfileVsMomentum_{}_{}".format(low, high)
            histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
            hist_filler.book_tprofile_fill(histogram_name,\
                                                      calc_trkP,\
                                                      calc_cone_e,\
                                                      selections = selections,\
                                                      bins = p_bins,\
                                                      xlabel ="P[GeV]",\
                                                      ylabel = "<E_{r#in[" + "{},{}".format(low_descr, high_descr) + "]}>[GeV]",\
                                                      )

            histogram_name = "EOPProfileVsMomentum_{}_{}".format(low, high)
            histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
            hist_filler.book_tprofile_fill(histogram_name,\
                                                      calc_trkP,\
                                                      calc_cone_eop,\
                                                      selections = selections,\
                                                      bins = p_bins,\
                                                      xlabel ="P[GeV]",\
                                                      ylabel = "<E_{r#in[" + "{},{}".format(low_descr, high_descr) + "]}/p>",\
                                                      )

            #book the histograms
            low_descr = float(low)/10.0
            high_descr = float(high)/10.0
            histogram_name = "EnergyAnnulusProfileVsMomentum_{}_{}_Area".format(low, high)
            histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
            hist_filler.book_tprofile_fill(histogram_name,\
                                                      calc_trkP,\
                                                      calc_cone_e_area,\
                                                      selections = selections,\
                                                      bins = p_bins,\
                                                      xlabel ="P[GeV]",\
                                                      ylabel = "<E_{r#in[" + "{},{}".format(low_descr, high_descr) + "]}>/Area [GeV]",\
                                                      )

            histogram_name = "EOPProfileVsMomentum_{}_{}_Area".format(low, high)
            histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
            hist_filler.book_tprofile_fill(histogram_name,\
                                                      calc_trkP,\
                                                      calc_cone_eop_area,\
                                                      selections = selections,\
                                                      bins = p_bins,\
                                                      xlabel ="P[GeV]",\
                                                      ylabel = "<E_{r#in[" + "{},{}".format(low_descr, high_descr) + "]}/p>/ Area",\
                                                      )

        histogram_name = "EnergyAnulusProfileVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        from eop_plotting.variables import calc_EnergyAnulus
        hist_filler.book_tprofile_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EnergyAnulus,\
                                                  selections = selections,\
                                                  bins = p_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "<E_{EM Anulus}>[GeV]",\
                                                  )

#       from variables import calc_EOTotalEMCalibHitEnergy
#       histogram_name = "EOTotalEMCalibHitEnergyProfileVsMomentum"  + "_" + "_" + description + "_Eta_" + str(eta_count)
#       hist_filler.book_tprofile_fill(histogram_name,\
#                                      calc_trkP,\
#                                      calc_EOTotalEMCalibHitEnergy,\
#                                      selections = selections,\
#                                      bins = p_bins,\
#                                      xlabel = "P[GeV]",\
#                                      ylabel = "<E_{Total Calibration}/P>",\
#                                      )


        histogram_name = "2DHist_EnergyAnulusVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        hist_filler.book_2dhistogram_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EnergyAnulus,\
                                                  selections = selections,\
                                                  bins_x = p_bins,\
                                                  bins_y = eop_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "E_{EM Anulus} [GeV]",\
                                                  )

        histogram_name = "EnergyBkgProfileVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        from eop_plotting.variables import calc_EOPBkg
        hist_filler.book_tprofile_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EOPBkg,\
                                                  selections = selections,\
                                                  bins = p_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "<E/p>_{BKG}",\
                                                  )

        histogram_name = "EnergyBkgUpProfileVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        from eop_plotting.variables import calc_EOPBkgUp
        hist_filler.book_tprofile_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EOPBkgUp,\
                                                  selections = selections,\
                                                  bins = p_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "<E/p>_{BKG}",\
                                                  )

        histogram_name = "EnergyBkgDownProfileVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        from eop_plotting.variables import calc_EOPBkgDown
        hist_filler.book_tprofile_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EOPBkgDown,\
                                                  selections = selections,\
                                                  bins = p_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "<E/p>_{BKG}",\
                                                  )

        histogram_name = "EnergyBigBkgProfileVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        from eop_plotting.variables import calc_EOPBigBkg
        hist_filler.book_tprofile_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EOPBigBkg,\
                                                  selections = selections,\
                                                  bins = p_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "<E/p>_{BKG}",\
                                                  )

        histogram_name = "EnergyBigBkgUpProfileVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        from eop_plotting.variables import calc_EOPBigBkgUp
        hist_filler.book_tprofile_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EOPBigBkgUp,\
                                                  selections = selections,\
                                                  bins = p_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "<E/p>_{BKG}",\
                                                  )

        histogram_name = "EnergyBigBkgDownProfileVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        from eop_plotting.variables import calc_EOPBigBkgDown
        hist_filler.book_tprofile_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EOPBigBkgDown,\
                                                  selections = selections,\
                                                  bins = p_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "<E/p>_{BKG}",\
                                                  )


        histogram_name = "2DHist_EnergyBkgVsMomentum"
        histogram_name = histogram_name + "_" + "_" + description + "_Eta_" + str(eta_count)
        hist_filler.book_2dhistogram_fill(histogram_name,\
                                                  calc_trkP,\
                                                  calc_EOPBkg,\
                                                  selections = selections,\
                                                  bins_x = p_bins,\
                                                  bins_y = eop_bins,\
                                                  xlabel ="P[GeV]",\
                                                  ylabel = "E/p BKG",\
                                                  )

        p_count = -1
        p_ranges = [(p_bins[i],p_bins[i+1]) for i in range(0, len(p_bins)-1)]
        for p_range in p_ranges:
            p_count += 1
            print("The prange is " + str(p_range))
            p_bin_selection = create_selection_function(PBin, ["trk_p"], p_range[0], p_range[1])
            selections = base_selection + [eta_bin_selection] + [p_bin_selection]

            histogram_name = "EOPDistribution" + "_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
            EOPDist  =  hist_filler.book_histogram_fill(histogram_name,
                                                      calc_EOP,\
                                                      selections = selections,\
                                                      bins = eop_bins,\
                                                      xlabel ="E/p",\
                                                      )

            if do_calib_hit_plots:
              from eop_plotting.variables import calc_CalibHitFrac, calc_PhotonCalibHitFrac, calc_HadronCalibHitFrac, sel_HasCalibHit
              from eop_plotting.variables import calc_EMCalibHitFrac, calc_PhotonEMCalibHitFrac, calc_HadronEMCalibHitFrac, sel_HasEMCalibHit
              from eop_plotting.variables import calc_HADCalibHitFrac, calc_PhotonHADCalibHitFrac, calc_HadronHADCalibHitFrac, sel_HasHADCalibHit

              histogram_name = "CalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_CalibHitFrac,\
                                                    selections = selections + [sel_HasCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    range_low_y = 0.0,\
                                                    range_high_y = 1.0,\
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{Calib}_{Track}/E^{Calib}_{Total}",\
                                                    )

              histogram_name = "PhotonCalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_PhotonCalibHitFrac,\
                                                    selections = selections + [sel_HasCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{Calib}_{Photons}/E^{Calib}_{Total}",\
                                                    )

              histogram_name = "HadronicCalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_HadronCalibHitFrac,\
                                                    selections = selections + [sel_HasCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{Calib}_{Neutral Hadrons}/E^{Calib}_{Total}",\
                                                    )

              histogram_name = "EMCalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_EMCalibHitFrac,\
                                                    selections = selections + [sel_HasEMCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{EM Calib}_{Track}/E^{EM Calib}_{Total}",\
                                                    )

              histogram_name = "PhotonEMCalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_PhotonEMCalibHitFrac,\
                                                    selections = selections + [sel_HasEMCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{EM Calib}_{Photons}/E^{EM Calib}_{Total}",\
                                                    )

              histogram_name = "HadronicEMCalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_HadronEMCalibHitFrac,\
                                                    selections = selections + [sel_HasEMCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{HAD Calib}_{Neutral Hadrons}/E^{HAD Calib}_{Total}",\
                                                    )

              histogram_name = "HADCalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_HADCalibHitFrac,\
                                                    selections = selections + [sel_HasHADCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{HAD Calib}_{Track}/E^{HAD Calib}_{Total}",\
                                                    )

              histogram_name = "PhotonHADCalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_PhotonHADCalibHitFrac,\
                                                    selections = selections + [sel_HasHADCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{HAD Calib}_{Photons}/E^{HAD Calib}_{Total}",\
                                                    )

              histogram_name = "HadronicHADCalibrationHitTwoDHist_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
              hist_filler.book_2dhistogram_fill(histogram_name,
                                                    calc_EOP,\
                                                    calc_HadronHADCalibHitFrac,\
                                                    selections = selections + [sel_HasHADCalibHit],\
                                                    bins_x = [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0],\
                                                    bins_y =list( np.linspace(0.0,1.0,20)),
                                                    xlabel ="E/p",\
                                                    ylabel = "E^{HAD Calib}_{Neutral Hadrons}/E^{HAD Calib}_{Neutral Hadrons}",\
                                                    )

            histogram_name = "EOPBkgDistribution" + "_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
            EOPBkgDist  =  hist_filler.book_histogram_fill(histogram_name,
                                                      calc_EOPBkg,\
                                                      selections = selections,\
                                                      bins = eop_bins,\
                                                      xlabel ="E/p Bkg",\
                                                      )
            histogram_name = "trkTRTHits" + "_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
            from eop_plotting.variables import calc_nTRT
            hist_filler.book_histogram_fill(histogram_name,\
                                   calc_nTRT,\
                                   selections = selections,\
                                   range_low = -0.5,\
                                   range_high = 59.5,\
                                   bins = 60,\
                                   xlabel = "Number of TRT Hits",\
                                   ylabel = "Number of Tracks")

            histogram_name = "trkEMDR100" + "_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
            from eop_plotting.variables import calc_EnergyEMDR100
            hist_filler.book_histogram_fill(histogram_name,\
                                   calc_EnergyEMDR100,\
                                   selections = selections,\
                                   range_low = -2.0,\
                                   range_high = + 10.0,\
                                   bins = 48,\
                                   xlabel = "E_{EM}^{#DeltaR<0.1}[GeV]",\
                                   ylabel = "Number of Tracks")

            histogram_name = "MomentumHadFrac" + "_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
            from eop_plotting.variables import calc_MomentumHadFrac
            hist_filler.book_histogram_fill(histogram_name,\
                                   calc_MomentumHadFrac,\
                                   selections = selections,\
                                   range_low = -1.0,\
                                   range_high = + 5.0,\
                                   bins = 48,\
                                   xlabel = "E^{HAD}/P",\
                                   ylabel = "Number of Tracks")

            histogram_name = "HadFrac" + "_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
            from eop_plotting.variables import calc_HadFrac
            hist_filler.book_histogram_fill(histogram_name,\
                                   calc_HadFrac,\
                                   selections = selections,\
                                   range_low = -1.0,\
                                   range_high = + 2.0,\
                                   bins = 48,\
                                   xlabel = "E^{HAD}/E^{Total}",\
                                   ylabel = "Number of Tracks")

            if do_cluster_plots:

               from eop_plotting.variables import calc_trkNClusters, calc_trkNClusters_EM, calc_trkNClusters_HAD,  calc_trkNClusters_emlike, calc_trkNClusters_hadlike
               histogram_names = ["NClusters","NClusters_EM","NClusters_HAD","NClusters_emlike","NClusters_hadlike"]
               xlabels = ["Number of Clusters","Number of Clusters in EM Calorimeter","Number of Clusters in HAD Calorimeter","Number of Clusters with EM Prob > 0.5","Number of Clusters with EM Prob < 0.5"]
               variables = [calc_trkNClusters, calc_trkNClusters_EM, calc_trkNClusters_HAD, calc_trkNClusters_emlike, calc_trkNClusters_hadlike]

               for histogram_name, variable, xlabel in zip(histogram_names, variables, xlabels):
                   histogram_name = histogram_name + "_" + description + "_Eta_" + str(eta_count) + "_Momentum_" + str(p_count)
                   hist_filler.book_histogram_fill(histogram_name,\
                                          variable,\
                                          selections = selections,\
                                          bins = 10,\
                                          range_low = -0.5,\
                                          range_high = 9.5,\
                                          xlabel=xlabel,\
                                          ylabel="Number of Tracks")
Пример #3
0
def fill_histograms(hist_filler, outputRootFileName):
    #import thje variables that we want to plot
    from variables import calc_trkNearestNeighbourEM2, calc_trkP, calc_EOP, calc_trkPt, calc_trkAverageMu, calc_trkEtaID, calc_trkEtaECAL, calc_trkNPV2, calc_trkCount, calc_trkNClusters, calc_trkNClusters_EM, calc_trkNClusters_HAD, calc_trkNClusters_emlike, calc_trkNClusters_hadlike, calc_TruthMomentum
    from selections import sel_HadIso
    from reweightings import book_reweighting
    hist_filler.apply_selection_for_channel(
        "LowMuDataTightIso", sel_TightIso)  #Tighter isolation requirement
    hist_filler.apply_selection_for_channel(
        "PythiaJetJetTightIso", sel_TightIso)  #Tighter isolation requirement
    hist_filler.apply_selection_for_channel(
        "PythiaJetJetHardScatter",
        sel_Truth)  #Those tracks truth matched to pions
    hist_filler.apply_selection_for_channel(
        "PythiaJetJetHardScatterTightIso",
        sel_Truth + sel_TightIso)  #Tighter isolation requirement
    book_reweighting(hist_filler, "nominal")
    hist_filler.create_subchannel_for_channel("PythiaJetJetHardScatterPion",
                                              "PythiaJetJetHardScatter",
                                              pion_selections)
    hist_filler.create_subchannel_for_channel("PythiaJetJetHardScatterPionPos",
                                              "PythiaJetJetHardScatter",
                                              pion_pos_selections)
    hist_filler.create_subchannel_for_channel("PythiaJetJetHardScatterPionNeg",
                                              "PythiaJetJetHardScatter",
                                              pion_neg_selections)
    hist_filler.create_subchannel_for_channel("PythiaJetJetHardScatterKaonPos",
                                              "PythiaJetJetHardScatter",
                                              kaon_pos_selections)
    hist_filler.create_subchannel_for_channel("PythiaJetJetHardScatterKaonNeg",
                                              "PythiaJetJetHardScatter",
                                              kaon_neg_selections)
    hist_filler.create_subchannel_for_channel(
        "PythiaJetJetHardScatterProtonPos", "PythiaJetJetHardScatter",
        proton_pos_selections)
    hist_filler.create_subchannel_for_channel(
        "PythiaJetJetHardScatterProtonNeg", "PythiaJetJetHardScatter",
        proton_neg_selections)
    hist_filler.create_subchannel_for_channel("PythiaJetJetHardScatterOther",
                                              "PythiaJetJetHardScatter",
                                              other_selections)
    outFile = ROOT.TFile(outputRootFileName, "RECREATE")

    #count the number of tracks in each channel
    histogram_name = "trkCount"
    selections = []
    trkCountHist = hist_filler.book_histogram_fill(histogram_name,\
                                                         calc_trkCount,\
                                                         selections = selections,\
                                                         bins = 1,\
                                                         range_low = -0.5,\
                                                         range_high = +0.5,\
                                                         xlabel ='Always 0',\
                                                         ylabel = 'Number of Tracks')

    #count the number of events in each channel
    histogram_name = "EventCount"
    selections = [sel_Event]
    trkCountHist = hist_filler.book_histogram_fill(histogram_name,\
                                                         calc_trkCount,\
                                                         selections = selections,\
                                                         bins = 1,\
                                                         range_low = -0.5,\
                                                         range_high = +0.5,\
                                                         xlabel ='Always 0',\
                                                         ylabel = 'Number Events')

    ################################################################################
    #plot the trk avaerage mu histogram
    histogram_name = "trkAverageMu"
    selections = []
    trkAverageMuHist = hist_filler.book_histogram_fill(histogram_name,\
                                                        calc_trkAverageMu,\
                                                        selections = selections,\
                                                        bins = 10,\
                                                        range_low = 0.0,\
                                                        range_high = 10.0,\
                                                        xlabel ='Average #mu of Event',\
                                                        ylabel = 'Number of Tracks')

    ################################################################################
    #plot a histogram of track NPV w/ 2 tracks
    histogram_name = "trkNPV2"
    trkNPV2Hist = hist_filler.book_histogram_fill(histogram_name,\
                                       calc_trkNPV2,\
                                       selections = [],\
                                       bins = 13,\
                                       range_low = -0.5,\
                                       range_high = 12.5,\
                                       xlabel ="NPV with 2 Tracks",\
                                       ylabel = "Number of Tracks")

    #   ################################################################################
    #plot a histogram of the average event NPV
    histogram_name = "eventNPV2Hist"
    eventNPV2Hist = hist_filler.book_histogram_fill(histogram_name,\
                                       calc_trkNPV2,\
                                       selections = [sel_Event],\
                                       bins = 13,\
                                       range_low = -0.5,\
                                       range_high = 12.5,\
                                       xlabel ="NPV with 2 Tracks",\
                                       ylabel = "Number Events")

    #   ################################################################################
    histogram_name = "eventAverageMu"
    selections = [sel_Event]
    eventAverageMuHist = hist_filler.book_histogram_fill(histogram_name,
                                          calc_trkAverageMu,\
                                          selections = selections,\
                                          bins = 10,\
                                          range_low = 0.0,\
                                          range_high = 10.0,\
                                          xlabel ='<#mu>',\
                                          ylabel = 'Number of Events')

    #    ################################################################################
    #plot the pt spectra of the tracks from 0.0 to 30.0 GeV
    #prepare the momentum bins
    binMax = 30.0
    binMin = 0.5
    nBins = 100
    p_bins = get_log_bins(binMin, binMax, nBins)
    p_bins_reference = p_bins
    histogram_name = "trkPtHist"
    hist_filler.book_histogram_fill(histogram_name,\
                                       calc_trkPt,\
                                       selections = [],\
                                       bins = p_bins,\
                                       xlabel ="Track P_{T} [GeV]",\
                                       ylabel = "Number of Tracks")

    hist_filler.book_histogram_fill(histogram_name + "HasExtrapolation",\
                                       calc_trkPt,\
                                       selections = [sel_hasHADExtrapolation],\
                                       bins = p_bins,\
                                       xlabel ="Track P_{T} [GeV]",\
                                       ylabel = "Number of Tracks")

    #    ################################################################################
    binMax = 30.0
    binMin = 0.5
    nBins = 50
    p_bins = get_log_bins(binMin, binMax, nBins)
    p_bins_reference = p_bins
    histogram_name = "LeadingPtTrkHist"
    trkPtHistZoom = hist_filler.book_histogram_fill(histogram_name,\
                                       calc_trkPt,\
                                       selections = [sel_Event],\
                                       bins = p_bins,\
                                       xlabel ="Track P_{T} [GeV]",\
                                       ylabel = "Number of Tracks")

    #    ################################################################################
    #prepare the momentum bins
    binMax = 30.0
    binMin = 0.5
    nBins = 50
    p_bins = get_log_bins(binMin, binMax, nBins)
    p_bins_reference = p_bins
    histogram_name = "SubleadingPtTrkHist"
    trkPtHistZoom = hist_filler.book_histogram_fill(histogram_name,\
                                       calc_trkPt,\
                                       selections = [sel_SubleadingTrack],\
                                       bins = p_bins,\
                                       xlabel ="Track P_{T} [GeV]",\
                                       ylabel = "Number of Tracks")

    from variables import calc_trkEtaECAL, calc_trkPhiECAL
    from selections import PBin, sel_NonZeroEnergy
    p_bin_selection = create_selection_function(PBin, ["trk_p"], 3., 4.)
    histogram_name = "TrkEtaPhiEMCal_MomentumBetween3And4GeV_Denomenator"
    hist_filler.book_2dhistogram_fill(histogram_name,\
                            calc_trkEtaECAL,\
                            calc_trkPhiECAL,\
                            selections=[p_bin_selection],\
                            bins_x = 200,\
                            bins_y = 200,\
                            range_low_y = -3.14,\
                            range_high_y = +3.14,\
                            range_low_x = -2.5,\
                            range_high_x = +2.5,\
                            xlabel = "#eta_{EMCal}",\
                            ylabel = "#phi_{EMCal}",\
                            zlabel = "Number of Tracks")

    histogram_name = "TrkEtaPhiEMCal_MomentumBetween3And4GeV_Numerator"
    hist_filler.book_2dhistogram_fill(histogram_name,\
                            calc_trkEtaECAL,\
                            calc_trkPhiECAL,\
                            selections=[p_bin_selection, sel_NonZeroEnergy],\
                            bins_x = 200,\
                            bins_y = 200,\
                            range_low_y = -3.14,\
                            range_high_y = +3.14,\
                            range_low_x = -2.5,\
                            range_high_x = +2.5,\
                            xlabel = "#eta_{EMCal}",\
                            ylabel = "#phi_{EMCal}",\
                            zlabel = "Number of Tracks")

    #try between 2 and 3 GeV

    p_bin_selection = create_selection_function(PBin, ["trk_p"], 2., 3.)
    histogram_name = "TrkEtaPhiEMCal_MomentumBetween2And3GeV_Denomenator"
    hist_filler.book_2dhistogram_fill(histogram_name,\
                            calc_trkEtaECAL,\
                            calc_trkPhiECAL,\
                            selections=[p_bin_selection],\
                            bins_x = 200,\
                            bins_y = 200,\
                            range_low_y = -3.14,\
                            range_high_y = +3.14,\
                            range_low_x = -2.5,\
                            range_high_x = +2.5,\
                            xlabel = "#eta_{EMCal}",\
                            ylabel = "#phi_{EMCal}",\
                            zlabel = "Number of Tracks")

    histogram_name = "TrkEtaPhiEMCal_MomentumBetween2And3GeV_Numerator"
    hist_filler.book_2dhistogram_fill(histogram_name,\
                            calc_trkEtaECAL,\
                            calc_trkPhiECAL,\
                            selections=[p_bin_selection, sel_NonZeroEnergy],\
                            bins_x = 200,\
                            bins_y = 200,\
                            range_low_y = -3.14,\
                            range_high_y = +3.14,\
                            range_low_x = -2.5,\
                            range_high_x = +2.5,\
                            xlabel = "#eta_{EMCal}",\
                            ylabel = "#phi_{EMCal}",\
                            zlabel = "Number of Tracks")

    ################################################################################
    histogramName = "TrackEtaID"
    hist_filler.book_histogram_fill(histogramName,\
                                       calc_trkEtaID,\
                                       selections = [],\
                                       bins = 100,\
                                       range_low = -5,\
                                       range_high = +5,\
                                       xlabel ="Track #eta ID",\
                                       ylabel = "Number of Tracks")

    #   ################################################################################
    histogramName = "TwoDTrackPvsTrkEtaID"
    max_bin = 2.4
    min_bin = -2.4
    nBins = 48
    eta_bins = get_bins(min_bin, max_bin, nBins)
    hist_filler.book_2dhistogram_fill(histogramName,\
                                             calc_trkEtaID,\
                                             calc_trkP,\
                                             selections=[],\
                                             bins_x=eta_bins,\
                                             xlabel="Track #eta ID",\
                                             bins_y=p_bins,\
                                             ylabel="Track P [GeV]",\
                                             zlabel="Number of Tracks",\
                                             )

    #   ################################################################################
    histogramName = "TwoDTrackPtVsEtaHistogram"
    hist_filler.book_2dhistogram_fill(histogramName,\
                                             calc_trkEtaID,\
                                             calc_trkPt,\
                                             selections=[],\
                                             bins_x=eta_bins,\
                                             xlabel="Track #eta ID",\
                                             bins_y=p_bins,\
                                             ylabel="Track P_{T} [GeV]",\
                                             zlabel="Number of Tracks",\
                                             )

    #   ################################################################################
    histogramName = "TwoDTrackPtVsEtaHistogram_HasExtrapolation"
    hist_filler.book_2dhistogram_fill(histogramName,\
                                             calc_trkEtaID,\
                                             calc_trkPt,\
                                             selections=[sel_hasHADExtrapolation],\
                                             bins_x=eta_bins,\
                                             xlabel="Track #eta ID",\
                                             bins_y=p_bins,\
                                             ylabel="Track P_{T} [GeV]",\
                                             zlabel="Number of Tracks",\
                                             )

    #   ################################################################################
    histogramName = "trkEtaECALHist"
    hist_filler.book_histogram_fill(histogramName,\
                                          calc_trkEtaECAL,
                                          selections = [],
                                          bins = 100,
                                          range_low = -5,
                                          range_high = +5,
                                          xlabel ="Track #eta EM Layer 2",
                                          ylabel = "Number of Tracks",
                                       )

    #   ################################################################################
    histogramName = "TwoDHistTrkPvsPhiInnerToExtrapolEM2"
    dPhi_bins = []
    min_bin = 0.0
    max_bin = pi
    NBins = 100
    dPhi_bins = get_bins(min_bin, max_bin, NBins)

    from variables import calc_trkDPhi
    hist_filler.book_2dhistogram_fill(histogramName,\
                                             calc_trkDPhi,\
                                             calc_trkPt,\
                                             selections=[],\
                                             bins_x=dPhi_bins,\
                                             xlabel="|#phi_{ID} - #phi_{EM2}|",\
                                             bins_y=p_bins,\
                                             ylabel="Track P_{T} [GeV]",\
                                             zlabel="Number of Tracks",\
                                             )

    #   ################################################################################
    histogramName = "lowPTLess07_TwoDHistTrkEtavsDEtaInnerToExtrapolEM2"
    from variables import calc_trkDEta
    from calculation import Calculation

    def lowPT(trk):
        return trk["trk_pt"] < 0.7

    branches = ["trk_pt"]
    sel_lowPT = Calculation(lowPT, branches)
    hist_filler.book_2dhistogram_fill(histogramName,\
                                             calc_trkEtaID,\
                                             calc_trkDEta,\
                                             selections=[sel_lowPT],\
                                             bins_x=50,\
                                             range_low_x=-2.5,\
                                             range_high_x=+2.5,\
                                             xlabel="Track #eta_{ID}",\
                                             bins_y=50,\
                                             range_low_y=0.0,\
                                             range_high_y=1.0,\
                                             ylabel="|#eta_{ID} - #eta_{EM2}|",\
                                             zlabel="Number of Tracks",\
                                             )

    #   ################################################################################
    from calculation import Calculation
    from selections import EtaBin
    sel_Eta00_08 = create_selection_function(EtaBin, ["trk_etaID"], 0.0, 0.8)
    histogramName = "EtaLess08_TwoDHistTrkPvsPhiInnerToExtrapolEM2"
    hist_filler.book_2dhistogram_fill(histogramName,\
                                             calc_trkDPhi,\
                                             calc_trkPt,\
                                             selections=[sel_Eta00_08],\
                                             bins_x=dPhi_bins,\
                                             xlabel="|#phi_{ID} - #phi_{EM2}|",\
                                             bins_y=p_bins,\
                                             ylabel="Track P_{T} [GeV]",\
                                             zlabel="Number of Tracks",\
                                             )

    #    ################################################################################
    histogramName = "NearestDRHist"
    hist_filler.book_histogram_fill(
        histogramName,
        calc_trkNearestNeighbourEM2,
        selections=[],
        bins=25,
        range_low=0.0,
        range_high=5,
        xlabel="dR to Nearest Track",
        ylabel="Number of Tracks",
    )

    from selections import sel_Lar1_1GeV, sel_EHadBetween30And90OfMomentum
    sel_NTRT20 = create_selection_function(NTRTX, ["trk_nTRT"], 20.0, 100000.0)
    MIP_selection = [
        sel_NTRT20, sel_Lar1_1GeV, sel_EHadBetween30And90OfMomentum
    ]

    ################################################################################
    selections = []
    histogramName = "InclusiveEOP"
    hist_filler.book_histogram_fill(histogramName,\
                                     calc_EOP,
                                     selections = selections,
                                     bins = 50,
                                     range_low = -1,
                                     range_high = 5,
                                     xlabel ="E/p",
                                     ylabel = "Number of Tracks",
                                     )

    ################################################################################
    from selections import sel_NonZeroEnergy
    selections = [sel_NonZeroEnergy]
    histogramName = "NonZeroEnergy_InclusiveEOP"
    hist_filler.book_histogram_fill(histogramName,\
                                     calc_EOP,
                                     selections = selections,
                                     bins = 50,
                                     range_low = -1,
                                     range_high = 5,
                                     xlabel ="E/p",
                                     ylabel = "Number of Tracks",
                                     )

    ################################################################################
    # This is figure 3a in the paper:

    selections = []
    binMax = 10.05
    binLow = 0.5
    nBins = 15
    bins = get_log_bins(binLow, binMax, nBins)

    histogramName = "InclusiveZeroFractionVsPDenomenator"
    hist_filler.book_histogram_fill(histogramName,\
                                          calc_trkP,\
                                          selections = selections,\
                                          bins = bins,\
                                          xlabel ="Track P [GeV]",\
                                          ylabel = "Number of Tracks",\
                                          )

    from selections import sel_ELessEqual0
    histogramName = "InclusiveZeroFractionVsPNumerator"
    selections = [sel_ELessEqual0]
    hist_filler.book_histogram_fill(histogramName,\
                                                    calc_trkP,\
                                                    selections = selections,\
                                                    bins = bins,\
                                                    xlabel ="Track P [GeV]",\
                                                    ylabel = "N(E<=0)/N",\
                                                    )

    ################################################################################
    #This is figure 3b of the paper
    bins = [
        -2.3, -1.8, -1.5, -1.4, -1.1, -0.6, 0.0, 0.6, 1.1, 1.4, 1.5, 1.8, 2.3
    ]
    selections = []
    histogramName = "InclusiveZeroFractionVsEtaDenomenator"
    hist_filler.book_histogram_fill(histogramName,\
                                              calc_trkEtaID,\
                                              selections = selections,\
                                              bins = bins,\
                                              xlabel ="Track |#eta|",\
                                              ylabel = "Number of Tracks",\
                                              )
    from selections import sel_ELessEqual0
    histogramName = "InclusiveZeroFractionVsEtaNumerator"
    selections = [sel_ELessEqual0]
    hist_filler.book_histogram_fill(histogramName,\
                                                   calc_trkEtaID,\
                                                   selections = selections,\
                                                   bins = bins,\
                                                   xlabel ="Track |#eta|",\
                                                   ylabel = "N(E<=0)/N",\
                                                   )

    ################################################################################
    bins = [0.0, 0.6, 1.1, 1.4, 1.5, 1.8, 2.3]
    from variables import calc_trkEta_ABS
    selections = []
    histogramName = "InclusiveZeroFractionVsAbsEtaDenomenator"
    hist_filler.book_histogram_fill(histogramName,\
                                              calc_trkEta_ABS,\
                                              selections = selections,\
                                              bins = bins,\
                                              xlabel ="Track |#eta|",\
                                              ylabel = "Number of Tracks",\
                                              )
    from selections import sel_ELessEqual0
    histogramName = "InclusiveZeroFractionVsAbsEtaNumerator"
    selections = [sel_ELessEqual0]
    hist_filler.book_histogram_fill(histogramName,\
                                                   calc_trkEta_ABS,\
                                                   selections = selections,\
                                                   bins = bins,\
                                                   xlabel ="Track |#eta|",\
                                                   ylabel = "N(E<=0)/N",\
                                                   )

    ################################################################################
    from variables import calc_trkEta_ABS
    from selections import EtaBin

    canvases = []
    keep_histograms_alive = []
    for (eta_bin_selection, eta_bin_description,
         eta_bin_edge) in zip(eta_bin_selections, eta_bin_descriptions,
                              eta_bin_tuples):
        center = (eta_bin_edge[0] + eta_bin_edge[1]) / 2.0
        binMax = 30.05
        binLow = get_p(0.5, center)
        nBins = 20
        bins = get_log_bins(binLow, binMax, nBins)

        #do the eta selection and count the inclusive number of tracks in the bin
        selections = [eta_bin_selection]
        histogramName = "ZeroFractionVsP" + eta_bin_description + "Denomenator"
        hist_filler.book_histogram_fill(histogramName,\
                                                  calc_trkP,\
                                                  selections = selections,\
                                                  bins = bins,\
                                                  xlabel ="Track P [GeV]",\
                                                  ylabel = "Number of tracks",\
                                                  )

        #do the eta selections and count the number of tracks with an energy deposity less than or equal to 0.0.
        from selections import sel_ELessEqual0
        selections = [sel_ELessEqual0] + [eta_bin_selection]
        histogramName = "ZeroFractionVsP" + eta_bin_description + "Numerator"
        hist_filler.book_histogram_fill(histogramName,\
                                                       calc_trkP,\
                                                       selections = selections,\
                                                       bins = bins,\
                                                       xlabel ="Track P [GeV]",\
                                                       ylabel = "N(E<=0)/N",\
                                                       )

    ################################################################################
    from variables import calc_trkEta_ABS
    base_description = ["N_{TRT hits} >= 20"]

    for (eta_bin_selection, eta_bin_description,
         eta_bin_edge) in zip(eta_bin_selections, eta_bin_descriptions,
                              eta_bin_tuples):
        center = (eta_bin_edge[0] + eta_bin_edge[1]) / 2.0
        binMax = 30.05
        binLow = get_p(0.5, center)
        nBins = 20
        bins = get_log_bins(binLow, binMax, nBins)

        #do the eta selection and count the inclusive number of tracks in the bin
        selections = [eta_bin_selection] + [sel_NTRT20]
        histogramName = "NTRT20ZeroFractionVsP" + eta_bin_description + "Denomenator"
        hist_filler.book_histogram_fill(histogramName,\
                                                  calc_trkP,\
                                                  selections = selections,\
                                                  bins = bins,\
                                                  xlabel ="Track P [GeV]",\
                                                  ylabel = "Number of tracks",\
                                                  )

        #do the eta selections and count the number of tracks with an energy deposity less than or equal to 0.0.
        from selections import sel_ELessEqual0
        selections = [sel_ELessEqual0] + [eta_bin_selection] + [sel_NTRT20]
        histogramName = "NTRT20ZeroFractionVsP" + eta_bin_description + "Numerator"
        hist_filler.book_histogram_fill(histogramName,\
                                                       calc_trkP,\
                                                       selections = selections,\
                                                       bins = bins,\
                                                       xlabel ="Track P [GeV]",\
                                                       ylabel = "N(E<=0)/N",\
                                                       )

    ################################################################################
    ##Create a set of p and eta bins for the measurement ##########################

    from selections import EtaBin, PBin
    from variables import calc_EOPBkg, calc_EnergyAnulus
    from selections import sel_NonZeroEnergy, sel_HardScatter

    ##select inclusive distributions
    ##Create a set of binned EOP response histograms
    #eta_ranges = eta_bin_tuples
    #base_selection = [sel_NTRT20, sel_Lar1_1GeV, sel_EHadBetween30And90OfMomentum]
    #p_bins_for_eta_range = []
    #for eta_range in eta_bin_tuples:
    #    p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
    #    p_bins = get_log_bins(p_bins_min, 30.05, 15)
    #    p_bins_for_eta_range.append(p_bins)
    #description = "MIPSelectionBetween30and90OfMomentum"
    #put_binning_vectors_in_file(outFile, eta_ranges, p_bins_for_eta_range, description)
    #create_eop_histograms(hist_filler, base_selection, eta_ranges, p_bins_for_eta_range, description)

    from selections import sel_EHadFracAbove70, sel_Lar1_1GeV
    eta_ranges = eta_bin_tuples
    base_selection = [sel_EHadFracAbove70, sel_NTRT20, sel_Lar1_1GeV]
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(p_bins_min, 30.05, 15)
        p_bins_for_eta_range.append(p_bins)
    description = "MIPSelectionHadFracAbove70"
    put_binning_vectors_in_file(outFile, eta_ranges, p_bins_for_eta_range,
                                description)
    create_eop_histograms(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)

    eta_ranges = eta_bin_tuples
    base_selection = [sel_NTRT20, sel_NonZeroEnergy]
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(p_bins_min, 30.05, 15)
        p_bins_for_eta_range.append(p_bins)
    description = "20TRTHitsNonZeroEnergy"
    put_binning_vectors_in_file(outFile, eta_ranges, p_bins_for_eta_range,
                                description)
    create_eop_histograms(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(p_bins_min, 40.05, 300)
        p_bins_for_eta_range.append(p_bins)
    create_spectrum_plots(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)

    eta_ranges = eta_bin_tuples
    base_selection = [sel_NTRT20]
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(p_bins_min, 30.05, 15)
        p_bins_for_eta_range.append(p_bins)
    description = "20TRTHits"
    put_binning_vectors_in_file(outFile, eta_ranges, p_bins_for_eta_range,
                                description)
    create_eop_histograms(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(p_bins_min, 40.05, 300)
        p_bins_for_eta_range.append(p_bins)
    create_spectrum_plots(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)

    eta_ranges = eta_bin_tuples
    base_selection = [sel_NonZeroEnergy]
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(p_bins_min, 30.05, 15)
        p_bins_for_eta_range.append(p_bins)
    description = "NonZeroEnergy"
    put_binning_vectors_in_file(outFile, eta_ranges, p_bins_for_eta_range,
                                description)
    create_eop_histograms(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(p_bins_min, 40.05, 300)
        p_bins_for_eta_range.append(p_bins)
    create_spectrum_plots(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)

    eta_ranges = eta_bin_tuples
    base_selection = []
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(p_bins_min, 30.05, 15)
        p_bins_for_eta_range.append(p_bins)
    description = "Inclusive"
    put_binning_vectors_in_file(outFile, eta_ranges, p_bins_for_eta_range,
                                description)
    create_eop_histograms(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)
    p_bins_for_eta_range = []
    for eta_range in eta_ranges:
        #p_bins_min = get_p(0.5, (eta_range[0] + eta_range[1]) / 2.0)
        p_bins = get_log_bins(0.5, 40.05, 300)
        p_bins_for_eta_range.append(p_bins)
    create_spectrum_plots(hist_filler, base_selection, eta_ranges,
                          p_bins_for_eta_range, description)

    histograms = hist_filler.DumpHistograms()
    for histogram_name in histograms:
        write_histograms(histograms[histogram_name], outFile)

    outFile.Close()

    print("THEJOBFINISHED!")