Exemplo n.º 1
0
def broadenspec(ms, E_0):
    spec = decayspec(ms, E_0)
    smear = core(E_0_center)
    newspec = TH1D("", "", spec.GetNbinsX(), -17.5, 17.5)
    for i in range(1, spec.GetNbinsX() + 1):
        newspec.SetBinContent(i, spec.GetBinContent(i))

    #x = RooRealVar("x","x",-30+E_0_center, 5+E_0_center)
    x = RooRealVar("x", "x", -17.5, 17.5)
    data = RooDataHist("", "", RooArgList(x), newspec)
    specpdf = RooHistPdf("", "", RooArgSet(x), data)
    #y = RooRealVar("y","y",-30, 5)
    x.setBins(10000)
    smearpdf = RooFit.bindPdf(smear, x)
    fft = RooFFTConvPdf("tt", "tt", x, specpdf, smearpdf)
    #fft.setShift(0, -18574)
    #c1 = TCanvas()
    #frame = x.frame()
    #fft.plotOn(frame)
    #frame.Draw()
    tf = fft.asTF(RooArgList(x))
    tf.SetNpx(10000)
    rtf = tf.Clone()
    return rtf
Exemplo n.º 2
0
    #return elas.EngLossPdf(epsilon[0]) * elascs + inelas.EngLossPdf(epsilon[0]) * inelascs
    return inelas.EngLossPdf(epsilon[0]) * inelascs


# Range from 0 to 500 eV to promote precision of FFT and avoid unphysical results.
fcn = TF1("pdf", totalCS, 0, 500)
fcn.SetNpx(npx)
x = RooRealVar("x", "x", 0, 500)
x.setBins(npx)
f = RooFit.bindPdf(fcn, x)
tt = RooFFTConvPdf("tt", "tt", x, f, f)
ttt = RooFFTConvPdf("ttt", "ttt", x, tt, f)

tf = []
tf.append(fcn)
tf.append(tt.asTF(RooArgList(x)))
tf.append(ttt.asTF(RooArgList(x)))

pdf = []
Times = ["once", "twice", "thrice"]
wfile = TFile("../EnergyLoss.root", "RECREATE")
for i in range(len(tf)):
    tf[i].SetNpx(npx)
    histtmp = tf[i].GetHistogram()
    histtmp.Scale(1 / histtmp.Integral("width"))
    # Change energy range to (0, 50)eV.
    hist = TH1D("", "", int(npx / 10), 0, 50)
    for nbin in range(1, int(npx / 10) + 1):
        hist.SetBinContent(nbin, histtmp.GetBinContent(nbin))
    hist.SetName("scat%d" % i)
    hist.GetXaxis().SetTitle("Energy loss [eV]")