Exemplo n.º 1
0
    def __init__(self, config, bin_center, bin_content, opt_t0, bkg_stat_noise, fit_boundary1, fit_boundary2, n_positron_hits):
        super(Fourier, self).__init__(config)
        self.bin_center = bin_center
        self.bin_content = bin_content
        self.opt_t0 = opt_t0
        self.fit_boundary1 = fit_boundary1
        self.fit_boundary2 = fit_boundary2
        self.bkg_stat_noise = bkg_stat_noise
        self.n_positron_hits = n_positron_hits

        # create the TCanvas for all the plots
        self.canvas_fourier = r.TCanvas('c_fourier', 'c_fourier', 900, 600)
        style.setTCanvasStyle(self.canvas_fourier)

        # create the TH1 to store the cosine and sine Fourier transforms
        self.cosine_histogram = r.TH1D(
            'cosine', 'cosine', self.n_freq_step, self.lower_freq, self.upper_freq)
        self.sine_histogram = r.TH1D(
            'sine', 'sine', self.n_freq_step, self.lower_freq, self.upper_freq)

        # create the TFile that will store the various results
        self.out_file2 = r.TFile(
            'results/' + self.tag + '/results.root', 'UPDATE')

        # when performing scan and wanting to keep in separate ROOT files
        # the results from each scan point
        if (self.print_plot >= 2):
            self.out_file = r.TFile('results/' + self.tag + '/results_t0_{0:.5f}_tS_{1}_tM_{2}_df_{3}.root'.format(
                self.opt_t0, self.tS, self.tM, self.freq_step_size), 'RECREATE')
Exemplo n.º 2
0
    def __init__(self, config):
        super(FastRotation, self).__init__(config)

        # define the time ranges to plot the various signal from tS t0 tS+self.times_to_plot in micro-seconds
        self.times_to_plot = [1, 10, 50, 100, 200, self.tM]

        # create the TCanvas for all the plots
        canvas_fastrotation = r.TCanvas(
            'c_fastrotation', 'c_fastrotation', 900, 600)
        style.setTCanvasStyle(canvas_fastrotation)

        # create output ROOT file to store the fast rotation signal
        self.out_file = r.TFile(
            'results/' + self.tag + '/fastrotation.root', 'RECREATE')
Exemplo n.º 3
0
colorList = [
    600, 601, 602, 603, 604, 599, 632, 633, 634, 635, 636, 631, 416, 417, 418,
    419, 420, 415, 616, 617, 618, 619, 620, 615
]

statCeMean = []
statXeMean = []
statWMean = []
statT0Mean = []
statCeStd = []
statXeStd = []
statWStd = []
statT0Std = []

c = r.TCanvas('c', 'c', 900, 600)
style.setTCanvasStyle(c)

#leg = r.TLegend(0.895,0.28,0.95,0.925)
leg = r.TLegend(0.15, 0.25, 0.23, 0.925)

for i in range(0, 24):
    fileList.append(
        r.TFile('../results/60h_nominal_calo' + str(i + 1) + '/results.root'))
    histoList.append(fileList[i].Get('rad'))
    style.setTH1Style(histoList[i], '', 'Radius [mm]', 'Arbitrary units')
    histoList[i].SetLineColor(colorList[i])
    histoList[i].SetMarkerColor(colorList[i])
    leg.AddEntry(histoList[i], '  calo ' + str(i + 1), "l")
    if (i == 0):
        histoList[i].Draw()
    else:
Exemplo n.º 4
0
    def produce(self):

        print(' ### Step 2/4: produce fast rotation signal\n')

        # open input ROOT file containing the input positron counts histogram
        in_file = r.TFile(self.root_file)

        # retrive and style input histogram
        self.histogram = in_file.Get(self.histo_name)
        style.setTH1Style(self.histogram, '', 'Time [#mus]', 'Intensity')

        # save input histogram to ROOT file
        self.out_file.cd()
        self.histogram.Write('positron_spectrum')

        # define and style canvas (canvas local to 'produce' method because not needed elsewhere)
        canvas_fastrotation = r.TCanvas(
            'c_fastrotation', 'c_fastrotation', 900, 600)
        style.setTCanvasStyle(canvas_fastrotation)

        # vary statistics in each bin of the input histogram if option specified
        if (self.stat_fluctuation):
            self.histogram = self.apply_stat_fluctutation()

        # rebin fast rotation histogram
        if (self.n_fit_param == 0):
            self.histogram.Rebin(self.rebin_frs_factor)

        # plot input histogram if option specified
        if (self.print_plot >= 2):
            for time in self.times_to_plot:
                plotting.plot(canvas_fastrotation, self.histogram, self.tag +
                              '/Intensity', self.tS, self.tS + time, self.tM)

        # check number of hits in positron spectrum if option specified
        if (self.check_positron_hits):
            n_positron_hits = self.histogram.Integral(
                self.histogram.FindBin(self.tS), self.histogram.FindBin(self.tM))
            if (self.verbose > 1):
                print(' Number of positron analyzed: ', n_positron_hits)
            if (n_positron_hits < self.positron_hits_threshold):
                print(' Warning -- low positron statistics: program exiting')
                sys.exit(1)
        else:
            n_positron_hits = -1

        # return histogram if no need for fit (typically for simulated fast rotation signals)
        if (self.n_fit_param == 0):
            # optimize tS and tM
            opt_tS, opt_tM = self.optimize_tS_tM()
            bin_center, bin_content = self.return_frs_np_array(self.histogram)

            # save signal to ROOT file
            self.out_file.cd()
            self.histogram.Write('fast_rotation')

            return opt_tS, opt_tM, n_positron_hits, bin_center, bin_content

        # clone input histogram to produce wiggle plot (histogram local to 'produce' method because not needed elsewhere)
        wiggle_histogram = self.histogram.Clone()

        # rebin cloned histograms
        wiggle_histogram.Rebin(self.rebin_wiggle_factor)

        # plot wiggle plot if option specified
        if (self.print_plot >= 2):
            for time in self.times_to_plot:
                plotting.plot(canvas_fastrotation, wiggle_histogram, self.tag +
                              '/Wiggle', self.tS, self.start_fit_time + time, self.tM)

        # fit wiggle plot (fit local to 'produce' method because not needed elsewhere)
        wiggle_fit = self.fit_wiggle(wiggle_histogram)

        # plot fitted wiggle plot if option specified
        if (self.print_plot >= 2):
            for time in self.times_to_plot:
                plotting.plot(canvas_fastrotation, wiggle_histogram, self.tag +
                              '/FittedWiggle', self.tS, self.start_fit_time + time, self.tM, wiggle_fit)

        # create histogram of the fit residuals
        residuals = wiggle_histogram
        residuals.GetYaxis().SetTitle('Residual [%]')
        for i in range(wiggle_histogram.GetNbinsX()):
            if (wiggle_histogram.GetBinContent(i+1) != 0):
                residuals.SetBinContent(i+1, (wiggle_histogram.GetBinContent(i+1)-wiggle_fit.Eval(
                    wiggle_histogram.GetBinCenter(i+1)))/wiggle_histogram.GetBinContent(i+1)*100)

        # plot histogram of residuals if option specified
        if (self.print_plot >= 2):
            for time in self.times_to_plot:
                plotting.plot(canvas_fastrotation, residuals, self.tag + '/Residuals',
                              self.tS, self.start_fit_time + time, self.tM)
                plotting.plot(canvas_fastrotation, residuals, self.tag + '/Residuals',
                              self.start_fit_time, self.start_fit_time + time, self.tM)

        # create fast rotation histogram
        for i in range(self.histogram.GetNbinsX()):
            self.histogram.SetBinContent(i+1, self.histogram.GetBinContent(i+1)/(
                wiggle_fit.Eval(self.histogram.GetBinCenter(i+1))/self.rebin_wiggle_factor))

        # rebin fast rotation histogram if option specified
        self.histogram.Rebin(self.rebin_frs_factor)

        # optimize tS and tM
        opt_tS, opt_tM = self.optimize_tS_tM()

        # plot frs plot if option specified
        if (self.print_plot >= 1):
            plotting.plot(canvas_fastrotation, self.histogram,
                          self.tag + '/FRS', 0, 10, self.tM)
            for time in self.times_to_plot:
                plotting.plot(canvas_fastrotation, self.histogram, self.tag +
                              '/FRS', round(opt_tS, 6), round(opt_tS + time, 6), round(opt_tM, 6))

        # save signal to ROOT file
        self.out_file.cd()
        self.histogram.Write('fast_rotation')

        # retrieve arrays of bin contents and bin centers
        bin_center, bin_content = self.return_frs_np_array(self.histogram)

        # return results
        return opt_tS, opt_tM, n_positron_hits, bin_center, bin_content