def analyseVariousNDFs(topFolder):
    os.chdir(topFolder)
    ndfItems = os.listdir(".")
    NDFVals = []
    print topFolder
    for ndfItem in ndfItems:
        if os.path.isdir(os.path.join(os.getcwd(), ndfItem)):
            NDFVals.append(ndfItem)

    print NDFVals
    dacValuesVarious = []
    peaks = []
    peaksErrors = []
    widths = []
    widthsErrors = []
    areas = []
    areasErrors = []
    for ndfFolder in NDFVals:
        folders = []
        ndfPath = os.path.join(os.getcwd(), ndfFolder, "dataset")
        items = os.listdir(ndfPath)
        for dacfolder in items:
            if os.path.isdir(os.path.join(ndfPath,
                                          dacfolder)) and is_number(dacfolder):
                folders.append(dacfolder)
        dacValues = []
        peakValues = []
        peakErrors = []
        FWHMValues = []
        FWHMErrors = []
        areaValues = []
        areaErrors = []
        folders.sort(key=int)
        for dacFolder in folders:
            print "THIS IS DAC FOLDER: " + str(dacFolder)
            x, y = calc_utils.readTRCFiles(os.path.join(ndfPath, dacFolder),
                                           False)
            areaHisto, area, areaErr = root_utils.plot_area(x, y, "area")
            widthHisto, width, widthErr = root_utils.plot_width(x, y, "FWHM")
            peakHisto, meanPeak, peakErr = root_utils.plot_peak(x, y, "peak")
            #numSqrt = np.sqrt(len(os.listdir(os.path.join(ndfPath,dacFolder))))
            peakValues.append(meanPeak)
            peakErrors.append(peakErr)
            FWHMValues.append(width)
            FWHMErrors.append(widthErr)
            areaValues.append(area)
            areaErrors.append(areaErr)
            dacValues.append(float(dacFolder))
        dacValuesVarious.append(dacValues)
        peaks.append(peakValues)
        peaksErrors.append(peakErrors)
        areas.append(areaValues)
        areasErrors.append(areaErrors)
    return NDFVals, dacValuesVarious, peaks, peaksErrors, areas, areasErrors
def analyseVariousNDFs(topFolder):
    os.chdir(topFolder)
    ndfItems  =  os.listdir(".")
    NDFVals = []
    print topFolder
    for ndfItem in ndfItems:
        if os.path.isdir(os.path.join(os.getcwd(),ndfItem)):
            NDFVals.append(ndfItem)

    print NDFVals
    dacValuesVarious = []
    peaks = []
    peaksErrors = []
    widths =[]
    widthsErrors = []
    areas = []
    areasErrors = []
    for ndfFolder in NDFVals:
        folders = []
        ndfPath = os.path.join(os.getcwd(),ndfFolder,"dataset")
        items = os.listdir(ndfPath)
        for dacfolder in items:
            if os.path.isdir(os.path.join(ndfPath,dacfolder)) and is_number(dacfolder):
                folders.append(dacfolder)
        dacValues = []
        peakValues = []
        peakErrors = []
        FWHMValues = []
        FWHMErrors = []
        areaValues = []
        areaErrors = []
        folders.sort(key=int)
        for dacFolder in folders:
            print "THIS IS DAC FOLDER: "+str(dacFolder)
            x,y = calc_utils.readTRCFiles(os.path.join(ndfPath,dacFolder),False)
            areaHisto, area, areaErr = root_utils.plot_area(x,y,"area")
            widthHisto, width, widthErr = root_utils.plot_width(x,y,"FWHM")
            peakHisto, meanPeak, peakErr = root_utils.plot_peak(x,y,"peak")
            #numSqrt = np.sqrt(len(os.listdir(os.path.join(ndfPath,dacFolder))))
            peakValues.append(meanPeak)
            peakErrors.append(peakErr)
            FWHMValues.append(width)
            FWHMErrors.append(widthErr)
            areaValues.append(area)
            areaErrors.append(areaErr)
            dacValues.append(float(dacFolder))
        dacValuesVarious.append(dacValues) 
        peaks.append(peakValues)
        peaksErrors.append(peakErrors)
        areas.append(areaValues)
        areasErrors.append(areaErrors)
    return NDFVals,dacValuesVarious,peaks,peaksErrors,areas,areasErrors
示例#3
0
topFolder = sys.argv[1]
os.chdir(topFolder)
items = os.listdir(".")
folders = []
for freqfolder in items:
    if os.path.isdir(freqfolder) and is_number(freqfolder[:-3]):
        print freqfolder[:-3]
        folders.append(freqfolder)

folders = sorted(folders, key=lambda x: int(x[:-2]))
print folders
for freqFolder in folders:
    print "THIS IS FREQ FOLDER: " + str(freqFolder)
    x, y = calc_utils.readTRCFiles(freqFolder, False)
    output = ROOT.TFile(freqFolder + ".root", "recreate")
    areaHisto, area, areaErr = root_utils.plot_area(x, y, "area")
    widthHisto, width, widthErr = root_utils.plot_width(x, y, "FWHM")
    peakHisto, meanPeak, peakErr = root_utils.plot_peak(x, y, "peak")
    numSqrt = np.sqrt(len(os.listdir(freqFolder)))
    areaHisto.Write()
    widthHisto.Write()
    peakHisto.Write()
    output.Close()
    peakValues.append(meanPeak)
    peakErrors.append(peakErr / numSqrt)
    FWHMValues.append(width)
    FWHMErrors.append(widthErr / numSqrt)
    areaValues.append(area)
    areaErrors.append(areaErr / numSqrt)
    freqValues.append(float(freqFolder[:-3]))
    for ent in channels:
        basePath = "./results/channel_%i" % ent
        file_names = find_data_filepaths(basePath, "run_")
        y_tot, count = [], 0

        for fileName in file_names:
            count = count + 1
            plotPath = check_dir("./results/plots/channel_%i/run_%i/" % (ent, count))
            f = ROOT.TFile("%sresults.root" % plotPath, "RECREATE")

            # Read in data file
            x, y = calc.readPickleChannel(fileName, 1)
            y_tot.append(y)

            # Make plots and save 
            area, a_mean, a_Err = ru.plot_area(x, y, "pmt signal")
            area.Write()
            ru.print_hist(area, "%sArea.pdf" % plotPath, c1)
            
            rise, r_mean, r_Err = ru.plot_rise(x, y, "pmt signal")
            rise.Write()
            ru.print_hist(rise, "%sRise.pdf" % plotPath, c1)
            
            fall, f_mean, f_Err = ru.plot_fall(x, y, "pmt signal")
            fall.Write()
            ru.print_hist(fall, "%sFall.pdf" % plotPath, c1)

            peak, p_mean, p_Err = ru.plot_peak(x, y, "pmt signal")
            peak.Write()
            ru.print_hist(peak, "%sPH.pdf" % plotPath, c1)
        ##############################################
示例#5
0
        basePath = "./results/channel_%i" % ent
        file_names = find_data_filepaths(basePath, "run_")
        y_tot, count = [], 0

        for fileName in file_names:
            count = count + 1
            plotPath = check_dir("./results/plots/channel_%i/run_%i/" %
                                 (ent, count))
            f = ROOT.TFile("%sresults.root" % plotPath, "RECREATE")

            # Read in data file
            x, y = calc.readPickleChannel(fileName, 1)
            y_tot.append(y)

            # Make plots and save
            area, a_mean, a_Err = ru.plot_area(x, y, "pmt signal")
            area.Write()
            ru.print_hist(area, "%sArea.pdf" % plotPath, c1)

            rise, r_mean, r_Err = ru.plot_rise(x, y, "pmt signal")
            rise.Write()
            ru.print_hist(rise, "%sRise.pdf" % plotPath, c1)

            fall, f_mean, f_Err = ru.plot_fall(x, y, "pmt signal")
            fall.Write()
            ru.print_hist(fall, "%sFall.pdf" % plotPath, c1)

            peak, p_mean, p_Err = ru.plot_peak(x, y, "pmt signal")
            peak.Write()
            ru.print_hist(peak, "%sPH.pdf" % plotPath, c1)
        ##############################################
areaFWHM = []
topFolder = sys.argv[1]
os.chdir(topFolder)
items  =  os.listdir(".")
folders = []
for dacfolder in items:
    if os.path.isdir(dacfolder) and is_number(dacfolder):
        folders.append(dacfolder)

folders.sort(key=int)
print folders
for dacFolder in folders:
    print "THIS IS DAC FOLDER: "+str(dacFolder)
    x,y = calc_utils.readTRCFiles(dacFolder,False)
    output = ROOT.TFile(dacFolder+".root","recreate")
    areaHisto,photonHisto, area, areaErr,areaErrOnMean = root_utils.plot_area(x,y,"area",lower_limit=9.e-8,upper_limit=9.e-8)
    widthHisto, width, widthErr, widthErrOnMean = root_utils.plot_width(x,y,"FWHM")
    peakHisto, meanPeak, peakErr, peakErrOnMean = root_utils.plot_peak(x,y,"peak")
    #numSqrt = np.sqrt(len(os.listdir(dacFolder)))
    photonHisto.Write()
    areaHisto.Write()
    widthHisto.Write()
    peakHisto.Write()
    output.Close()
    peakValues.append(meanPeak)
    peakErrors.append(peakErrOnMean)
    FWHMValues.append(width)
    FWHMErrors.append(widthErrOnMean)
    areaValues.append(area)
    areaErrors.append(areaErrOnMean)
    print "Area MEAN is: "+str(area)
topFolder = sys.argv[1]
os.chdir(topFolder)
items  =  os.listdir(".")
folders = []
for freqfolder in items:
    if os.path.isdir(freqfolder) and is_number(freqfolder[:-3]):
        print freqfolder[:-3]
        folders.append(freqfolder)

folders = sorted(folders,key=lambda x:int(x[:-2]))
print folders
for freqFolder in folders:
    print "THIS IS FREQ FOLDER: "+str(freqFolder)
    x,y = calc_utils.readTRCFiles(freqFolder,False)
    output = ROOT.TFile(freqFolder+".root","recreate")
    areaHisto, area, areaErr = root_utils.plot_area(x,y,"area")
    widthHisto, width, widthErr = root_utils.plot_width(x,y,"FWHM")
    peakHisto, meanPeak, peakErr = root_utils.plot_peak(x,y,"peak")
    numSqrt = np.sqrt(len(os.listdir(freqFolder)))
    areaHisto.Write()
    widthHisto.Write()
    peakHisto.Write()
    output.Close()
    peakValues.append(meanPeak)
    peakErrors.append(peakErr/numSqrt)
    FWHMValues.append(width)
    FWHMErrors.append(widthErr/numSqrt)
    areaValues.append(area)
    areaErrors.append(areaErr/numSqrt)
    freqValues.append(float(freqFolder[:-3]))
    # File stuff
    dataPath = "./results/"
    runs = [1, 2, 3, 4, 5]
    for i in runs:
        run = "run_%i" % i
        fileName = "%s%s.pkl" % (dataPath, run)
        plotPath = "./results/plots/run_%i/" % i
        f = ROOT.TFile("%sresults.root" % plotPath, "RECREATE")

        # Read in data file
        x1, y1 = calc.readPickleChannel(fileName, 1)
        x2, y2 = calc.readPickleChannel(fileName, 2)

        # Make plots and save
        area_trig, aT_mean, aT_Err = rootu.plot_area(x1, y1, "trigger")
        area_sig, aS_mean, aS_Err = rootu.plot_area(x2, y2, "signal")
        area_trig.Write()
        area_sig.Write()
        rootu.print_hist(area_trig, "%sArea_trig.pdf" % plotPath, c1)
        rootu.print_hist(area_sig, "%sArea_sig.pdf" % plotPath, c1)

        rise_trig, rT_mean, rT_Err = rootu.plot_rise(x1, y1, "trigger")
        rise_sig, rS_mean, rS_Err = rootu.plot_rise(x2, y2, "signal")
        rise_trig.Write(), rise_sig.Write()
        rootu.print_hist(rise_trig, "%sRise_trig.pdf" % plotPath, c1)
        rootu.print_hist(rise_sig, "%sRise_sig.pdf" % plotPath, c1)

        fall_trig, fT_mean, fT_Err = rootu.plot_fall(x1, y1, "trigger")
        fall_sig, fS_mean, fS_Err = rootu.plot_fall(x2, y2, "signal")
        fall_trig.Write(), fall_sig.Write()
示例#9
0
areaFWHM = []
topFolder = sys.argv[1]
os.chdir(topFolder)
items = os.listdir(".")
folders = []
for dacfolder in items:
    if os.path.isdir(dacfolder) and is_number(dacfolder):
        folders.append(dacfolder)

folders.sort(key=int)
print folders
for dacFolder in folders:
    print "THIS IS DAC FOLDER: " + str(dacFolder)
    x, y = calc_utils.readTRCFiles(dacFolder, False)
    output = ROOT.TFile(dacFolder + ".root", "recreate")
    areaHisto, photonHisto, area, areaErr, areaErrOnMean = root_utils.plot_area(
        x, y, "area", lower_limit=9.e-8, upper_limit=9.e-8)
    widthHisto, width, widthErr, widthErrOnMean = root_utils.plot_width(
        x, y, "FWHM")
    peakHisto, meanPeak, peakErr, peakErrOnMean = root_utils.plot_peak(
        x, y, "peak")
    #numSqrt = np.sqrt(len(os.listdir(dacFolder)))
    photonHisto.Write()
    areaHisto.Write()
    widthHisto.Write()
    peakHisto.Write()
    output.Close()
    peakValues.append(meanPeak)
    peakErrors.append(peakErrOnMean)
    FWHMValues.append(width)
    FWHMErrors.append(widthErrOnMean)
    areaValues.append(area)