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
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])) areaFile = open("areas.txt", "w") peakFile = open("peaks.txt", "w")
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) ############################################## # make containing data from all recorded runs ############################################## # Make plots and save plotPath = check_dir("./results/plots/channel_%i/" % (ent)) f = ROOT.TFile("%sresults.root" % plotPath, "RECREATE") 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)
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) print "Area RMS is: "+str(areaErr) areaFWHM.append(2*np.sqrt(2*np.log(2))*areaErr)
# 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() rootu.print_hist(fall_trig, "%sFall_trig.pdf" % plotPath, c1) rootu.print_hist(fall_sig, "%sFall_sig.pdf" % plotPath, c1) peak_trig, pT_mean, pT_Err = rootu.plot_peak(x1, y1, "trigger") peak_sig, pS_mean, pS_Err = rootu.plot_peak(x2, y2, "signal") peak_trig.Write(), peak_sig.Write() rootu.print_hist(peak_trig, "%sPH_trig.pdf" % plotPath, c1) rootu.print_hist(peak_sig, "%sPH_sig.pdf" % plotPath, c1) jitter_hist, jitt_mean, jitt_Err = rootu.plot_jitter( x1, y1, x2, y2, "Pulse sep") jitter_hist.Write() rootu.print_hist(jitter_hist, "%sJitter.pdf" % plotPath, c1)