Beispiel #1
0
def geometric_carrier_trapping(eventIDs):
    filename = r"C:\Users\alexp\Documents\UW\Research\Selenium\aSe0vBB\particle\selenium-build\output\122_keV_testTuple.root"
    emfilename = r"C:\Users\alexp\Documents\UW\Research\Selenium\Coplanar Detector\sim_data\kapton_layer_analysis_5um_spacing_fullsize.txt"
    configfilename = r"./config.txt"

    settings = sc.readConfigFile(configfilename)

    newCollection = pd.gEventCollection(filename)
    newCollection.printInfo()
    bmap = brewer2mpl.get_map("Set2", "Qualitative", max(len(eventIDs) + 1,
                                                         3)).mpl_colors

    fig, ax = plt.subplots()

    for colorj, j in enumerate(eventIDs):
        settings["CARRIER_LIFETIME_GEOMETRIC"] = 1
        event = newCollection.collection[j]

        # Iterate over many scenarios to watch fluctuations
        N = 30
        qtot = 0

        for i in range(N):
            print(i)

            t, q = pd.computeChargeSignal(event, emfilename, **settings)
            ax.plot(t, -q / 1.6e-19 * 0.05, color=bmap[colorj], alpha=0.3)
            qtot += q

        ax.plot(
            t,
            -qtot / N / 1.6e-19 * 0.05,
            color=bmap[colorj],
            linewidth=2,
            label="Noise, Event ID %i" % event.GetEventID(),
        )
        ax.set_xlabel(r"Time ($\mu$s)", fontsize=14)
        ax.set_ylabel(r"Induced Charge (keV)", fontsize=14)
        ax.set_title(
            "Q(t), expressed as energy, on a Coplanar Detector (5 $\mu m$ thickness kapton, 280 V bias) \n with Carrier Trapping Fluctuation. Scaling",
            fontsize=16,
        )

        settings["CARRIER_LIFETIME_GEOMETRIC"] = 0
        t, q = pd.computeChargeSignal(event, emfilename, **settings)
        ax.plot(t,
                -q / 1.6e-19 * 0.05,
                color="black",
                linewidth=1,
                label="No Noise")
    ax.legend()
    return fig, ax
def testScaleFactor():

    filename = r"C:\Users\alexp\Documents\UW\Research\Selenium\aSe0vBB\particle\selenium-build\output\122_keV_testTuple.root"

    emfilename = r"C:\Users\alexp\Documents\UW\Research\Selenium\Coplanar Detector\sim_data\kapton_layer_analysis_5um_spacing_fullsize.txt"

    gCollection = pd.gEventCollection(filename)
    event = gCollection.collection[146]
    configfilename = r"./config.txt"

    allhits = event.GetHits()
    etot = 0
    for i in allhits:
        etot += i["energy"]

    print (etot)
    print (allhits[1]["y"])

    event.plotH2()

    settings = sc.readConfigFile(configfilename)

    settings["SCALE_WEIGHTED_PHI"] = 1

    t, q = pd.computeChargeSignal(event, emfilename, **settings)

    settings["SCALE_WEIGHTED_PHI"] = 0

    tt, qq = pd.computeChargeSignal(event, emfilename, **settings)

    # fig, ax = plt.subplots()
    # ax.plot(t, -q, 'k', linewidth=3)
    # ax.plot(tt, -qq, '-b', linewidth=3)
    # ax.set_xlabel(r'Time ($\mu s$)', fontsize=14)
    # ax.set_ylabel(r'Induced Charge (C)', fontsize=14)
    # ax.legend(['Scaled', 'Not Scaled'])

    # return fig, ax
    return etot
def signalAnalysis():
    filename = r"C:\Users\alexp\Documents\UW\Research\Selenium\aSe0vBB\particle\selenium-build\output\122_keV_testTuple.root"
    emfilename = [
        r"C:\Users\alexp\Documents\UW\Research\Selenium\Coplanar Detector\sim_data\kapton_layer_analysis_1um_spacing_fullsize.txt",
        r"C:\Users\alexp\Documents\UW\Research\Selenium\Coplanar Detector\sim_data\kapton_layer_analysis_3um_spacing_fullsize.txt",
        r"C:\Users\alexp\Documents\UW\Research\Selenium\Coplanar Detector\sim_data\kapton_layer_analysis_5um_spacing_fullsize.txt",
        r"C:\Users\alexp\Documents\UW\Research\Selenium\Coplanar Detector\sim_data\kapton_layer_analysis_8um_spacing_fullsize.txt",
    ]
    configfilename = r"./config.txt"

    print ("Read settings")
    settings = sc.readConfigFile(configfilename)

    print ("Read Geant4 Particle data")
    newCollection = pd.gEventCollection(filename)
    event = newCollection.collection[140]
    creatorProc = event.GetHits()[1]["creatorProcess"].split("\x00")[0]

    print ("Calculating induced charge signal")
    for file in emfilename:
        biasVoltIndex = [0, 1, 2, 3, 4]
        plt.rc("font", family="serif")
        fig, ax = plt.subplots()
        bmap = brewer2mpl.get_map("Set1", "Qualitative", 5).mpl_colors
        biasString = ["120 V", "160 V", "200 V", "240 V", "280 V"]
        for indx in biasVoltIndex:
            print (indx)
            settings["VOLTAGE_SWEEP_INDEX"] = indx
            time, q = pd.computeChargeSignal(event, file, **settings)
            ax.plot(time, -q, linewidth=2, color=bmap[indx], label=biasString[indx])

        ax.set_xlabel(r"Time ($\mu s$)", fontsize=14)
        ax.set_ylabel(r"Induced Charge (C)", fontsize=14)
        ax.set_title(
            "Induced Charge Signal at Amplifier for %s Kapton layer"
            % file.split("\\")[-1].split("_")[3]
        )
        ax.legend()

    return fig, ax
Beispiel #4
0
def noise_histogram():
    filename = r"C:\Users\alexp\Documents\UW\Research\Selenium\aSe0vBB\particle\selenium-build\output\122_keV_testTupleLarge.root"
    emfilename = r"C:\Users\alexp\Documents\UW\Research\Selenium\Coplanar Detector\sim_data\kapton_layer_analysis_5um_spacing_fullsize.txt"
    configfilename = r"./config.txt"

    settings = sc.readConfigFile(configfilename)

    # For planar detector
    settings["CHARGE_DIFFERENCE"] = 1
    settings["VOLTAGE_SWEEP_INDEX"] = 4
    settings["SCALE_WEIGHTED_PHI"] = 1

    # color scheme
    bmap = brewer2mpl.get_map("Dark2", "Qualitative", 5).mpl_colors

    # Read event data
    collection = pd.gEventCollection(filename)
    event = collection.collection[125]

    N = 50
    wehp = 0.05  # keV
    e = 1.6e-19

    energy = []
    charge = []
    charge1usNoTrapping = []
    charge20usNoTrapping = []
    charge1usTrapping = []
    charge20usTrapping = []
    allfig = []
    allax = []

    for i in range(N):

        print(i)

        energy.append(sum(event.energy))

        # nehp, nehpFluctuations, _, _ = event.createCarriers(**settings)
        # totalCharge = np.sum((nehp + nehpFluctuations) * wehp)
        # charge.append(totalCharge)

        # No Trapping
        settings["CARRIER_LIFETIME_GEOMETRIC"] = 0
        t, qNo = pd.computeChargeSignal(event, emfilename, **settings)
        indx1us = np.where(t > 1)[0][0]
        indx20us = np.where(t > 20)[0][0]
        charge1usNoTrapping.append(-qNo[indx1us] / e * wehp)
        charge20usNoTrapping.append(-qNo[indx20us] / e * wehp)

        # Trapping
        settings["CARRIER_LIFETIME_GEOMETRIC"] = 1
        t, qTrap = pd.computeChargeSignal(event, emfilename, **settings)
        indx1us = np.where(t > 0.5)[0][0]
        indx20us = np.where(t > 22)[0][0]
        charge1usTrapping.append(-qTrap[indx1us] / e * wehp)
        charge20usTrapping.append(-qTrap[indx20us] / e * wehp)

    fig, ax = plt.subplots()
    ax.plot(t, -qTrap)
    # Energy histogram
    fig, ax = plt.subplots()
    ax.hist(energy,
            bins=100,
            range=(100, 140),
            histtype="step",
            linewidth=2,
            color=bmap[0])
    ax.set_title("Energy Deposited in Event %i" % event.GetEventID(),
                 fontsize=16)
    ax.set_xlabel("Energy (keV)", fontsize=14)
    allfig.append(fig), allax.append(ax)

    # Charge creation histogram
    # fig, ax = plt.subplots()
    # ax.hist(charge, bins=100, range=(100,140),  histtype='step', linewidth=2, color=bmap[0])
    # ax.set_title('Charge Created with Poisson Fluctuations in Event %i' % event.GetEventID(), fontsize=16)
    # ax.set_xlabel('Energy (keV)', fontsize=14)

    # Induced charge, trapping
    fig, ax = plt.subplots()
    ax.hist(
        charge1usTrapping,
        bins=122,
        range=(0, 122),
        histtype="step",
        linewidth=2,
        color=bmap[0],
        label="1 $\mu s$",
    )
    ax.hist(
        charge20usTrapping,
        bins=122,
        range=(0, 122),
        histtype="step",
        linewidth=2,
        color=bmap[1],
        label="20 $\mu s$",
    )
    ax.set_title(
        "Charge Induced at Planar Detector (Poisson and Trapping Fluctuations) in Event %i"
        % event.GetEventID(),
        fontsize=16,
    )
    ax.set_xlabel("Energy (keV)", fontsize=14)
    ax.legend()
    allfig.append(fig), allax.append(ax)

    # Induced charge, no trapping
    fig, ax = plt.subplots()
    ax.hist(
        charge1usNoTrapping,
        bins=122,
        range=(0, 122),
        histtype="step",
        linewidth=2,
        color=bmap[0],
        label="1 $\mu s$",
    )
    ax.hist(
        charge20usNoTrapping,
        bins=122,
        range=(0, 122),
        histtype="step",
        linewidth=2,
        color=bmap[1],
        label="20 $\mu s$",
    )
    ax.set_title(
        "Charge Induced at Planar Detector (Poisson and No Trapping Fluctuations) in Event %i"
        % event.GetEventID(),
        fontsize=16,
    )
    ax.set_xlabel("Energy (keV)", fontsize=14)
    ax.legend()
    allfig.append(fig), allax.append(ax)

    return allfig, allax
Beispiel #5
0
def charge_compute_wrapper(event, emfilename, e, wehp, neg, **settings):
    t, qNo = pd.computeChargeSignal(event, emfilename, **settings)
    indx1us = np.where(t > 1.5)[0][0]
    indx20us = t.size - 1
    return neg * qNo[indx1us] / e * wehp, neg * qNo[indx20us] / e * wehp