コード例 #1
0
ファイル: cv58.py プロジェクト: regkwee/LHC-Collimation
def cv58():

    formatTRKFILE = [
        ("X", np.float),
        ("Y", np.float),
        ("Z", np.float),
        ("TXX", np.float),
        ("TYY", np.float),
        ("TZZ", np.float),
        ("CTRACK", np.float),
        ("CMTRACK", np.float),
        ("ATRACK", np.float),
    ]

    formatfort89 = [
        ("CXTRCK", np.float),
        ("CYTRCK", np.float),
        ("CZTRCK", np.float),
        ("XTRACK", np.float),
        ("YTRACK", np.float),
        ("ZTRACK", np.float),
        ("JTRACK", np.int),
        ("NCASE", np.int),
        ("ATRACK", np.float),
    ]

    fname = "ir1_6500GeV_b1_20MeV_orbitDumpINICON001_fort.89"
    fname = "inicon1/createTrajectories/run_00001/ir1_6500GeV_b1_20MeV_orbitDumpINICON001_fort.89"
    #fname = "ir1_6500GeV_b1_20MeV_orbitDump001_TRAKFILE"

    format, xvar, yvar = formatfort89, "ZTRACK", "YTRACK"

    fileDType = np.dtype(format)
    fdata = np.loadtxt(fname, dtype=fileDType)

    # keep order
    xList = fdata[xvar].tolist()
    yList = fdata[yvar].tolist()
    color = kRed
    mStyle = 6
    gr = makeTGraph(xList, yList, color, mStyle)

    hname = "trajectory"
    a, b = 1, 1
    cv = TCanvas('cv' + hname, 'cv' + hname, 10, 10, a * 900, b * 600)
    cv.Divide(a, b)

    gr.Draw('ap')
    pname = "~/public/www/HL-LHC/TCT/6.5TeV/beamgas/plt.png"

    cv.SaveAs(pname)
コード例 #2
0
ファイル: cv79.py プロジェクト: regkwee/LHC-Collimation
def cv79():

    for pFile, xTitle, lText in pData:
        # get data
        data = getdata5c(pFile)

        # plot data as is
        rel = 'pressureEq'

        cv = TCanvas('cv' + rel + lText, 'cv' + rel + lText, 2100, 900)
        cv.SetLogy(1)
        #cv.SetGridy(1)
        x1, y1, x2, y2 = 0.8, 0.65, 0.9, 0.9
        mlegend = TLegend(x1, y1, x2, y2)
        mlegend.SetFillColor(0)
        mlegend.SetFillStyle(0)
        mlegend.SetLineColor(0)
        mlegend.SetTextSize(0.035)
        mlegend.SetShadowColor(0)
        mlegend.SetBorderSize(0)

        mg = TMultiGraph(rel, rel)
        lm = 'l'

        totalPress = getTotalPressure(data)

        xlist, ylist, col, mstyle, lg = data[
            's'], totalPress, kBlack, 21, 'total'
        g4 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g4, lg, lm)
        mg.Add(g4)

        xlist, ylist, col, mstyle, lg = data['s'], data[
            'H2_Eq'], kTeal - 3, 22, 'H_{2}'
        g0 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g0, lg, lm)
        mg.Add(g0)

        xlist, ylist, col, mstyle, lg = data['s'], data[
            'CH4_Eq'], kMagenta + 1, 24, 'CH_{4}'
        g1 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g1, lg, lm)
        mg.Add(g1)

        xlist, ylist, col, mstyle, lg = data['s'], data[
            'CO2_Eq'], kAzure + 4, 33, 'CO_{2}'
        g2 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g2, lg, lm)
        mg.Add(g2)

        xlist, ylist, col, mstyle, lg = data['s'], data[
            'CO_Eq'], kRed - 2, 21, 'CO'
        g3 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g3, lg, lm)
        mg.Add(g3)

        mg.Draw("al")

        mg.SetTitle("pressure profiles")
        mg.GetXaxis().SetTitle(xTitle)
        mg.GetYaxis().SetTitle("pressure equivalent [mbar]")
        mg.GetYaxis().SetRangeUser(5e-15, 1e-5)
        mlegend.Draw()
        lab = mylabel(42)
        lab.DrawLatex(0.45, 0.88, lText)

        pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/6500GeV'
        pname = pFile.split('.txt')[0] + "_pressureEq.pdf"
        print('Saving file as ' + pname)
        cv.Print(pname)

        # ---------------------------------------------------
        # plot data as rho
        rel = 'rho'
        cv = TCanvas('cvrho' + lText, 'cvrho' + lText, 2100, 900)
        cv.SetLogy(1)
        #cv.SetGridy(1)
        x1, y1, x2, y2 = 0.8, 0.65, 0.9, 0.9
        mlegend = TLegend(x1, y1, x2, y2)
        mlegend.SetFillColor(0)
        mlegend.SetFillStyle(0)
        mlegend.SetLineColor(0)
        mlegend.SetTextSize(0.035)
        mlegend.SetShadowColor(0)
        mlegend.SetBorderSize(0)

        mg = TMultiGraph(rel, rel)
        lm = 'pl'

        xlist, ylist, col, mstyle, lg = data['s'], getrho(
            totalPress), kBlack, 21, 'total'
        g4 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g4, lg, lm)
        mg.Add(g4)

        xlist, ylist, col, mstyle, lg = data['s'], getrho(
            data['H2_Eq']), kTeal - 3, 22, 'H_{2}'
        g0 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g0, lg, lm)
        mg.Add(g0)

        xlist, ylist, col, mstyle, lg = data['s'], getrho(
            data['CH4_Eq']), kMagenta + 1, 24, 'CH_{4}'
        g1 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g1, lg, lm)
        mg.Add(g1)

        xlist, ylist, col, mstyle, lg = data['s'], getrho(
            data['CO2_Eq']), kAzure + 4, 33, 'CO_{2}'
        g2 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g2, lg, lm)
        mg.Add(g2)

        xlist, ylist, col, mstyle, lg = data['s'], getrho(
            data['CO_Eq']), kRed - 2, 21, 'CO'
        g3 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g3, lg, lm)
        mg.Add(g3)

        mg.Draw("al")

        mg.SetTitle("pressure profiles")
        mg.GetXaxis().SetTitle(xTitle)
        mg.GetYaxis().SetTitle("density [molecules/m^{3}]")
        mg.GetYaxis().SetRangeUser(5e5, 1e16)
        mlegend.Draw()
        lab = mylabel(42)
        lab.DrawLatex(0.45, 0.88, lText)

        pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/6500GeV'
        pname = pFile.split('.txt')[0] + "_" + rel + ".pdf"
        print('Saving file as ' + pname)
        cv.Print(pname)

        # ---------------------------------------------------
        # plot data as rho
        rel = 'rho'
        cv = TCanvas('cvrho' + lText, 'cvrho' + lText, 2100, 900)
        cv.SetLogy(1)
        #cv.SetGridy(1)
        x1, y1, x2, y2 = 0.8, 0.65, 0.9, 0.9
        mlegend = TLegend(x1, y1, x2, y2)
        mlegend.SetFillColor(0)
        mlegend.SetFillStyle(0)
        mlegend.SetLineColor(0)
        mlegend.SetTextSize(0.035)
        mlegend.SetShadowColor(0)
        mlegend.SetBorderSize(0)

        mg = TMultiGraph(rel, rel)
        lm = 'pl'

        xlist, ylist, col, mstyle, lg = data['s'], getrho(
            totalPress), kBlack, 21, 'total'
        g4 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g4, lg, lm)
        mg.Add(g4)

        rho_H2 = getrho(data['H2_Eq'])
        xlist, ylist, col, mstyle, lg = data[
            's'], rho_H2, kTeal - 3, 22, 'H_{2}'
        g0 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g0, lg, lm)
        mg.Add(g0)

        rho_CH4 = getrho(data['CH4_Eq'])
        xlist, ylist, col, mstyle, lg = data[
            's'], rho_CH4, kMagenta + 1, 24, 'CH_{4}'
        g1 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g1, lg, lm)
        mg.Add(g1)

        rho_CO2 = getrho(data['CO2_Eq'])
        xlist, ylist, col, mstyle, lg = data[
            's'], rho_CO2, kAzure + 4, 33, 'CO_{2}'
        g2 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g2, lg, lm)
        mg.Add(g2)

        rho_CO = getrho(data['CO_Eq'])
        xlist, ylist, col, mstyle, lg = data['s'], rho_CO, kRed - 2, 21, 'CO'
        g3 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g3, lg, lm)
        mg.Add(g3)

        mg.Draw("al")

        mg.SetTitle("pressure profiles")
        mg.GetXaxis().SetTitle(xTitle)
        mg.GetYaxis().SetTitle("density [molecules/m^{3}]")
        mg.GetYaxis().SetRangeUser(5e5, 1e16)
        mlegend.Draw()
        lab = mylabel(42)
        lab.DrawLatex(0.45, 0.88, lText)

        pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/6500GeV'
        pname = pFile.split('.txt')[0] + "_" + rel + ".pdf"
        print('Saving file as ' + pname)
        cv.Print(pname)

        # ---------------------------------------------------
        # plot atomic rho
        rel = 'atomicrho'
        cv = TCanvas('cv' + rel + lText, 'cv' + rel + lText, 2100, 900)
        cv.SetLogy(1)
        #cv.SetGridy(1)
        x1, y1, x2, y2 = 0.8, 0.7, 0.9, 0.9
        mlegend = TLegend(x1, y1, x2, y2)
        mlegend.SetFillColor(0)
        mlegend.SetFillStyle(0)
        mlegend.SetLineColor(0)
        mlegend.SetTextSize(0.035)
        mlegend.SetShadowColor(0)
        mlegend.SetBorderSize(0)

        mg = TMultiGraph(rel, rel)
        lm = 'pl'

        rho_H, rho_C, rho_O = getAtomicRho(rho_H2, rho_CH4, rho_CO, rho_CO2)

        rho_total_atomic = [
            rho_H[i] + rho_C[i] + rho_O[i] for i in range(len(rho_O))
        ]
        xlist, ylist, col, mstyle, lg = data[
            's'], rho_total_atomic, kBlack, 20, 'total'
        g3 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g3, lg, lm)
        mg.Add(g3)

        xlist, ylist, col, mstyle, lg = data['s'], rho_H, kTeal + 3, 22, 'H'
        g0 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g0, lg, lm)
        mg.Add(g0)

        xlist, ylist, col, mstyle, lg = data['s'], rho_O, kAzure - 4, 33, 'O'
        g2 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g2, lg, lm)
        mg.Add(g2)

        xlist, ylist, col, mstyle, lg = data['s'], rho_C, kMagenta - 1, 24, 'C'
        g1 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g1, lg, lm)
        mg.Add(g1)

        mg.Draw("al")

        mg.SetTitle("pressure profiles")
        mg.GetXaxis().SetTitle(xTitle)
        mg.GetYaxis().SetTitle("density [atoms/m^{3}]")
        mg.GetYaxis().SetRangeUser(5e5, 1e16)
        mlegend.Draw()
        lab = mylabel(42)
        lab.DrawLatex(0.45, 0.88, lText)

        pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/6500GeV'
        pname = pFile.split('.txt')[0] + "_" + rel + ".pdf"
        print('Saving file as ' + pname)
        cv.Print(pname)

        # ---------------------------------------------------
        # plot pint
        rel = 'pint'
        cv = TCanvas('cv' + rel + lText, 'cv' + rel + lText, 2100, 900)
        cv.SetLogy(1)
        #cv.SetGridy(1)
        x1, y1, x2, y2 = 0.8, 0.72, 0.9, 0.92
        mlegend = TLegend(x1, y1, x2, y2)
        mlegend.SetFillColor(0)
        mlegend.SetFillStyle(0)
        mlegend.SetLineColor(0)
        mlegend.SetTextSize(0.035)
        mlegend.SetShadowColor(0)
        mlegend.SetBorderSize(0)

        mg = TMultiGraph(rel, rel)
        lm = 'l'
        pint_H, pint_C, pint_O, pint_tot = getpint(rho_H, rho_C, rho_O)

        xlist, ylist, col, mstyle, lg = data[
            's'], pint_tot, kBlack, 20, 'total'
        g3 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g3, lg, lm)
        mg.Add(g3)

        xlist, ylist, col, mstyle, lg = data['s'], pint_H, kTeal + 3, 22, 'H'
        g0 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g0, lg, lm)
        mg.Add(g0)

        xlist, ylist, col, mstyle, lg = data['s'], pint_O, kAzure - 4, 33, 'O'
        g2 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g2, lg, lm)
        mg.Add(g2)

        xlist, ylist, col, mstyle, lg = data[
            's'], pint_C, kMagenta - 1, 24, 'C'
        g1 = makeTGraph(xlist, ylist, col, mstyle)
        mlegend.AddEntry(g1, lg, lm)
        mg.Add(g1)

        mg.Draw("al")

        mg.SetTitle("pressure profiles")
        mg.GetXaxis().SetTitle(xTitle)
        mg.GetYaxis().SetTitle("interaction probability")
        mg.GetYaxis().SetRangeUser(5e-19, 1e-10)
        mlegend.Draw()
        lab = mylabel(42)
        lab.DrawLatex(0.45, 0.88, lText)

        pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/6500GeV/'
        pname = pFile.split('.txt')[0].split("/")[-1] + "_" + rel + ".pdf"
        print('Saving file as ' + pname)
        cv.Print(pname)
コード例 #3
0
ファイル: cv40.py プロジェクト: regkwee/LHC-Collimation
def cv40():

    # twiss file
    tf = pymadx.Tfs(
        '/afs/cern.ch/work/r/rkwee/HL-LHC/LHC-Collimation/SixTrackConfig/6.5TeV/MED800/B1/twiss_lhcb1_med_new_thin_800.tfs'
    )

    BETX = tf.GetColumn('BETX')
    BETY = tf.GetColumn('BETY')
    ALFX = tf.GetColumn('ALFX')
    ALFY = tf.GetColumn('ALFY')
    X = tf.GetColumn('X')
    Y = tf.GetColumn('Y')
    PX = tf.GetColumn('PX')
    PY = tf.GetColumn('PY')
    S = tf.GetColumn('S')
    IP5 = tf.GetColumnDict('S')['IP5']
    IP8 = tf.GetColumnDict('S')['IP8']

    XurMin, XurMax = length_LHC - 300, length_LHC
    rel = '_IR1Left'
    XurMin, XurMax = 0, 300
    rel = '_IR1Right'
    XurMin, XurMax = IP5 - 300, IP5 + 300
    rel = '_IP5'
    XurMin, XurMax = IP8 - 300, IP8 + 300
    rel = '_IP8'

    XurMin, XurMax = -1, -1
    rel = '_phasespace'

    cv = TCanvas('cv', 'cv', 900, 900)

    x1, y1, x2, y2 = 0.8, 0.65, 0.9, 0.9
    mlegend = TLegend(x1, y1, x2, y2)
    mlegend.SetFillColor(0)
    mlegend.SetFillStyle(0)
    mlegend.SetLineColor(0)
    mlegend.SetTextSize(0.035)
    mlegend.SetShadowColor(0)
    mlegend.SetBorderSize(0)

    mg = TMultiGraph()
    # marker in legend
    lm = 'p'

    xList, yList, color, mStyle, lg = X, PX, kGreen + 1, 21, "x,x'"
    g1 = makeTGraph(xList, yList, color, mStyle)
    mlegend.AddEntry(g1, lg, lm)
    mg.Add(g1)

    xList, yList, color, mStyle, lg = Y, PY, kBlue + 1, 27, "y,y'"
    g3 = makeTGraph(xList, yList, color, mStyle)
    mlegend.AddEntry(g3, lg, lm)
    mg.Add(g3)

    mg.Draw("a" + lm)
    mg.GetXaxis().SetTitle('x,y')
    if XurMin != -1:
        mg.GetXaxis().SetRangeUser(XurMin, XurMax)

    mlegend.Draw()

    pname = wwwpath
    subfolder = 'TCT/6.5TeV/beamgas/'
    pname += subfolder + 'twiss_b1' + rel + '.png'

    print('Saving file as ' + pname)
    cv.Print(pname)
コード例 #4
0
ファイル: cv75.py プロジェクト: regkwee/LHC-Collimation
def cv75():

    # twiss file

    do4TeV = 0
    if do4TeV:
        tf = pymadx.Tfs(
            "/afs/cern.ch/work/r/rkwee/HL-LHC/LHC-Collimation/SixTrackConfig/4TeV/beamgas/twiss_b4.data.thin"
        )
        energy = "4TeV"
        gamma_rel = 4e3 / 0.938
        betaStar = 0.6

    else:
        tf = pymadx.Tfs(
            '/afs/cern.ch/work/r/rkwee/HL-LHC/LHC-Collimation/SixTrackConfig/6.5TeV/MED800/B1/twiss_lhcb1_med_new_thin_800.tfs'
        )
        gamma_rel = 6.5e3 / 0.938
        energy = '6.5TeV'
        betaStar = 0.8

    print energy, "." * 45
    BETX = tf.GetColumn('BETX')
    BETY = tf.GetColumn('BETY')
    S = tf.GetColumn('S')

    # print "first elements of twiss betax", BETX[100:200]
    # print "first elements of twiss betay", BETY[100:200]
    # no shift if val is length

    shiftVal = length_LHC  #-500

    cnt = 0

    S_shifted, X_shifted = [], []
    for s in S:
        s_shifted = s + shiftVal
        #print "s_shifted", s_shifted

        if s_shifted >= length_LHC:
            cnt += 1
            s_shifted -= length_LHC
            #print "s_shifted after subtraction", s_shifted

        S_shifted += [s_shifted]
        #print "using", s_shifted

    S_shifted.sort()

    XurMin, XurMax = 0, 548.
    #XurMin, XurMax = 0,5.
    rel = '_compsigma_IR1Right_' + energy

    lShift = 0.0
    # -----------------------------------------------
    # fluka part from cv74

    # full sample at 4 TeV
    #filename = projectpath + 'HaloRun2/valBG4TeV2/oneFileAllTraj.dat.89.root'

    filename = projectpath + 'HaloRun2/valBG4TeV2/traj_fort.89.10.root'  # as used in fluka simulations
    filename = projectpath + '4TeVBGnoBS/createTrajectories6p5_checkfix/runs_fix/ir1_6500GeV_b1_20MeV_orbitDumpINICON_89.root'  # fixed version of inicons
    filename = projectpath + '4TeVBGnoBS/createTrajectories6p5_checkrepfix/run_repfix/ir1_6500GeV_b1_20MeV_orbitDumpINICON_89.root'  # fixed version of inicons
    # sufficient trajectories at 6.5 TeV
    #if not do4TeV:   filename = '/afs/cern.ch/project/lhc_mib/HaloRun2/valBG4TeV2/400Traj.fort.89.root'

    print "Opening", filename
    rf = TFile.Open(filename)
    mt = rf.Get("particle")
    SIGXflu = []  # getStatErrFromTProf(mt, "XTRACK",-1000.,1)
    #    SIGYflu1 = getStatErrFromTProf(mt, "YTRACK",0.,2) # to cut off outlier use only up to s=1000cm
    #    SIGYflu2 = getStatErrFromTProf(mt, "YTRACK",-1.,2)# then use this when outlier is gone

    #   SIGYflu  = [ SIGYflu1[i] for i in range(1001)]
    #   SIGYflu += [ SIGYflu2[i] for i in range(1001,54694)]

    SIGYflu = []  # getStatErrFromTProf(mt, "YTRACK",-1.,2)
    srange_meter = [0.01 * s for s in range(54694)]

    a, b = 1, 1
    cv = TCanvas('cv', 'cv', a * 2100, b * 900)
    cv.Divide(a, b)
    cv.cd(1)

    x1, y1, x2, y2 = 0.5 - lShift, 0.65, 0.9 - lShift, 0.9
    mlegend = TLegend(x1, y1, x2, y2)
    mlegend.SetFillColor(0)
    mlegend.SetFillStyle(0)
    mlegend.SetLineColor(0)
    mlegend.SetTextSize(0.05)
    mlegend.SetShadowColor(0)
    mlegend.SetBorderSize(0)

    mg = TMultiGraph()
    # marker in legend
    lm = 'lp'

    emittance_norm = 3.5e-6
    emittance_geo = emittance_norm / gamma_rel

    SIGX = [math.sqrt(betax * emittance_geo) for betax in BETX]
    SIGY = [math.sqrt(betay * emittance_geo) for betay in BETY]
    for S in SIGY:
        if S in SIGX:

            print "?>>> S in both??", S
    SIGMAX = [s * 1000. for s in SIGX]
    xList, yList, color, mStyle, lg = S_shifted, SIGMAX, kGreen - 1, 22, '#sigma_{x} from Twiss'
    g0 = makeTGraph(xList, yList, color, mStyle)
    mlegend.AddEntry(g0, lg, lm)
    mg.Add(g0)

    print '-' * 11, lg
    SIGMAY = [s * 1000 for s in SIGY]
    xList, yList, color, mStyle, lg = S_shifted, SIGMAY, kGreen - 2, 20, '#sigma_{y} from Twiss'
    g1 = makeTGraph(xList, yList, color, mStyle)
    #    mlegend.AddEntry(g1, lg, lm)
    #   mg.Add(g1)
    ytitle = 'beam size [mm]'
    print '-' * 11, lg
    print S_shifted[:10], srange_meter[:10]

    SIGYfluka = [s * 10 for s in SIGYflu]
    xList, yList, color, mStyle, lg = srange_meter, SIGYfluka, kGreen + 1, 21, '#sigma_{y} from fluka'
    g2 = makeTGraph(xList, yList, color, mStyle)
    #    mlegend.AddEntry(g2, lg, lm)
    #mg.Add(g2)
    print '-' * 11, lg

    SIGXfluka = [s * 10. for s in SIGXflu]
    xList, yList, color, mStyle, lg = srange_meter, SIGXfluka, kBlue + 1, 27, "#sigma_{x} from fluka"
    g3 = makeTGraph(xList, yList, color, mStyle)
    mlegend.AddEntry(g3, lg, lm)
    mg.Add(g3)
    print '-' * 11, lg
    sigxflu_x, sigxtwi_x, sigxflu_y, sigxtwi_y = ROOT.Double(), ROOT.Double(
    ), ROOT.Double(), ROOT.Double()
    collectNp = []
    for i in range(20, len(SIGYflu)):
        g3.GetPoint(i, sigxflu_x, sigxflu_y)
        g1.GetPoint(i, sigxtwi_x, sigxtwi_y)
        ratiosigx = 0.
        if sigxtwi_y: ratiosigx = sigxflu_y**2 / sigxtwi_y**2
        newEmittance = emittance_norm * ratiosigx
        collectNp += [ratiosigx]
        print "New emittance", newEmittance, " dev:", collectNp[
            -1], "at ", srange_meter[
                i], "sigxflu", sigxflu_y, "sigxtwi", sigxtwi_y

    print "max deviation", max(collectNp), "at ", collectNp.index(
        max(collectNp)),

    mg.Draw("a" + lm)

    l = TLine()
    l.SetLineStyle(1)
    YurMin, YurMax = 0, 0.0019
    l.SetLineColor(kRed)

    s = 22.6
    l.DrawLine(s, YurMin, s, YurMax)

    s = 59.
    l.DrawLine(s, YurMin, s, YurMax)

    s = 153.
    l.DrawLine(s, YurMin, s, YurMax)

    s = 269.
    l.DrawLine(s, YurMin, s, YurMax)

    mg.GetYaxis().SetTitle(ytitle)
    mg.GetXaxis().SetTitle('s [m]')
    if XurMin != -1:
        mg.GetXaxis().SetRangeUser(XurMin, XurMax)

    mlegend.Draw()
    pname = wwwpath
    subfolder = 'TCT/' + energy + '/beamgas/'
    pname += subfolder + 'from_twiss_b1' + rel + '.png'

    print('Saving file as ' + pname)
    cv.Print(pname)
コード例 #5
0
def cv82():
    # ---------------------------------------------------
    rel = 'allpinttot'
    cv = TCanvas( 'cv'+ rel , 'cv'+rel , 2100, 900)
    cv.SetLogy(0)
    cv.SetGridy(0)
    x1, y1, x2, y2 = 0.75, 0.72, 0.88, 0.92
    mlegend = TLegend( x1, y1, x2, y2)
    mlegend.SetFillColor(0)
    mlegend.SetFillStyle(0)
    mlegend.SetLineColor(0)
    mlegend.SetTextSize(0.035)
    mlegend.SetShadowColor(0)
    mlegend.SetBorderSize(0)

    mg = TMultiGraph(rel,rel)
    lm = 'l'
    
    grs = []
    
    for i,( pFile, xTitle, lText) in enumerate(pData):

        print "Getting data from file", pFile
        fillnumber = pFile.split("Density_")[1].split('b_26')[0] + 'b'
        print  "."*33
        data = cv79.getdata5c(pFile)

        s_incoming = []
        
        # only one side, chose positive s
        s_positiveb1, s_positiveb2 = [],[]

        for cs in data['s']:
            s = float(cs)
            if s<0.:
                s_positiveb1 += [-s]
            else:
                s_positiveb2 += [s]
                
        print "len(s_positiveb1)",len(s_positiveb1)
        print "len(s_positiveb2)",len(s_positiveb2)


        rho_H2, rho_CH4, rho_CO, rho_CO2 = cv79.getrho(data['H2_Eq']),cv79.getrho(data['CH4_Eq']),cv79.getrho(data['CO_Eq']),cv79.getrho(data['CO2_Eq'])
        rho_H, rho_C, rho_O = cv79.getAtomicRho(rho_H2, rho_CH4, rho_CO, rho_CO2)
        pint_H, pint_C, pint_O, pint_tot = cv79.getpint(rho_H, rho_C, rho_O)

        pint_incoming, pint_tot_incomingbeam = [],[]
        if lText.count("B2"):
            pint_tot_incomingbeam = pint_tot[len(s_positiveb2):]
            s_incoming = s_positiveb2[:len(s_positiveb2)-1]
        else:
            pint_tot_incomingbeam = [p for p in pint_tot[:len(s_positiveb1)+1]]
            s_incoming = s_positiveb1

        print "len(pint_tot_incomingbeam)", len(pint_tot_incomingbeam)
        print "len(s_incoming)", len(s_incoming)
        xlist, ylist, col, mstyle, lg = s_incoming,pint_tot_incomingbeam , kBlack+i,20+i, lText
        grs += [ makeTGraph(xlist, ylist, col, mstyle)]
        mlegend.AddEntry(grs[-1], lg, lm)    
        mg.Add(grs[-1])

    mg.Draw("al")

    mg.SetTitle("pressure profiles")
    mg.GetXaxis().SetTitle(xTitle)
    mg.GetYaxis().SetTitle("total interaction probability")
    mg.GetYaxis().SetRangeUser(5e-18,4e-10)
    mlegend.Draw()
    lab = mylabel(42)
    lab.DrawLatex(0.42, 0.82, 'incoming beams 6.5 TeV') 

    pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/6500GeV'
    pname = "pint_"+rel+".pdf"
    print('Saving file as ' + pname )
    cv.Print(pname)

        
コード例 #6
0
def cv85():
    # ---------------------------------------------------
    rel = 'comppint'
    # rel = 'compallpress'
    a, b = 1, 1
    cv = TCanvas('cv' + rel, 'cv' + rel, a * 2100, b * 900)
    cv.Divide(a, b)
    cv.SetLogy(1)
    cv.SetGridy(0)
    x1, y1, x2, y2 = 0.75, 0.6, 0.88, 0.94
    mlegend = TLegend(x1, y1, x2, y2)
    mlegend.SetFillColor(0)
    mlegend.SetFillStyle(0)
    mlegend.SetLineColor(0)
    mlegend.SetTextSize(0.035)
    mlegend.SetShadowColor(0)
    mlegend.SetBorderSize(0)

    mg = TMultiGraph(rel, rel)
    lm = 'l'

    grs = []

    for i, (pFile, xTitle, lText) in enumerate(pData):

        print "Getting data from file", pFile

        print "." * 33
        data = {}
        if pFile.count("LSS1"):
            data = cv32.getdata14c(pFile)
            stmp, rho_C, rho_H, rho_O = cv65.getAtomicRho(data)
            stmp2 = stmp[1:]
            s_full = stmp2[::-1]
            moleculeKeys = ['H2_N2Eq', 'CH4_N2Eq', 'CO_N2Eq', 'CO2_N2Eq']

            for j in range(1, len(data['H2_N2Eq'])):
                sumPress = 0.
                for mk in moleculeKeys:
                    sumPress += float(data[mk][j])
                totalPress += [sumPress]

        else:
            data = cv79.getdata5c(pFile)
            totalPress = cv79.getTotalPressure(data)
            pressCO = data['CO_Eq']
            pressCO2 = data['CO2_Eq']
            pressCH4 = data['CH4_Eq']
            pressH2 = data['H2_Eq']

            s_full = data['s']

        s_incoming = []

        # only one side, chose positive s
        s_positiveb1, s_positiveb2 = [], []

        #print s_full
        for cs in s_full:
            s = float(cs)
            if s < 0.:
                s_positiveb1 += [-s]
            else:
                s_positiveb2 += [s]

        print "len(s_positiveb1)", len(s_positiveb1)
        print "len(s_positiveb2)", len(s_positiveb2)

        if lText.count("B2"):
            lenposb2 = len(s_positiveb2)
            press_tot_incomingbeam = totalPress[lenposb2:]
            pressH2_incoming = pressH2[lenposb2:]
            pressCO_incoming = pressCO[lenposb2:]
            pressCH4_incoming = pressCH4[lenposb2:]
            pressCO2_incoming = pressCO2[lenposb2:]

            s_incoming = s_positiveb2[:len(s_positiveb2) - 1]
        else:
            press_tot_incomingbeam = [
                p for p in totalPress[:len(s_positiveb1) + 1]
            ]
            pressH2_incoming = pressH2[:len(s_positiveb1) + 1]
            pressCO_incoming = pressCO[:len(s_positiveb1) + 1]
            pressCH4_incoming = pressCH4[:len(s_positiveb1) + 1]
            pressCO2_incoming = pressCO2[:len(s_positiveb1) + 1]

            s_incoming = s_positiveb1
            if pFile.count("LSS"):
                press_tot_incomingbeam = totalPress[::-1]

                print s_incoming[:100], press_tot_incomingbeam[:100]

        xlist, ylist, col, mstyle, lg = s_incoming, press_tot_incomingbeam, cols[
            i], 20 + i, lText + 'total'
        grs += [makeTGraph(xlist, ylist, col, mstyle)]
        mlegend.AddEntry(grs[-1], lg, lm)
        mg.Add(grs[-1])

        print "plot added"
        # xlist, ylist, col, mstyle, lg = s_incoming,pressH2_incoming , cols[i]+1, 20,lText + 'H2'
        # grs += [ makeTGraph(xlist, ylist, col, mstyle)]
        # mlegend.AddEntry(grs[-1], lg, lm)
        # mg.Add(grs[-1])

        # xlist, ylist, col, mstyle, lg = s_incoming,pressCH4_incoming , cols[i]+2, 20,lText + 'CH4'
        # grs += [ makeTGraph(xlist, ylist, col, mstyle)]
        # mlegend.AddEntry(grs[-1], lg, lm)
        # mg.Add(grs[-1])

        # xlist, ylist, col, mstyle, lg = s_incoming,pressCO2_incoming , cols[i]+2, 20,lText + 'CO2'
        # grs += [ makeTGraph(xlist, ylist, col, mstyle)]
        # mlegend.AddEntry(grs[-1], lg, lm)
        # mg.Add(grs[-1])

        # xlist, ylist, col, mstyle, lg = s_incoming,pressCO_incoming , cols[i]+2, 20,lText + 'CO'
        # grs += [ makeTGraph(xlist, ylist, col, mstyle)]
        # mlegend.AddEntry(grs[-1], lg, lm)
        # mg.Add(grs[-1])

    mg.Draw("al")

    #mg.SetTitle("pressure profiles")
    mg.GetXaxis().SetTitle(xTitle)
    mg.GetYaxis().SetTitle("total interaction probability")
    #mg.GetYaxis().SetTitle("total pressure [mbar]")
    mg.GetYaxis().SetRangeUser(5e-18, 4e-10)
    #mg.GetYaxis().SetRangeUser(5e-15,4e-3)
    mlegend.Draw()
    lab = mylabel(42)
    lab.DrawLatex(0.42, 0.82, 'incoming beams')

    pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/6500GeV/'
    pname = rel + ".pdf"
    print('Saving file as ' + pname)
    cv.Print(pname)
コード例 #7
0
ファイル: cv45.py プロジェクト: regkwee/LHC-Collimation
def cv45():

    # current path
    cpath = workpath + 'runs/checkTrajectory6500GeV/4TeV/'
    cpath = '/afs/cern.ch/project/lhc_mib/beamgas/6500GeV_beamsize/'
    cpath = thispath + 
    trakfiles = [
        # filen name, Xindex, Yindex, markerstyle, 
        # ['/afs/cern.ch/work/r/rkwee/HL-LHC/runs/checkTrajectory6500GeV/madSY_b2.dat', 0,1, kGreen+1, 21, ],
        # [cpath + 'ir1b2_exp001_TRAKFILE.luigi', 2,1, kBlue+1, 27, ],
        # [cpath + 'ir1b2_exp001_TRAKFILE.145', 2,1, kBlue+1, 23, ],
        # [cpath + 'madSYX_b2_thin.dat', 0,1, kGreen-1, 21, 'madx thin seq'], #plots x:s 2,0,  1,0 plots y:s
        # [cpath + 'madSYX_b2_thick.dat', 0,1, kBlue-1, 22, 'madx thick seq'],
        # [cpath + 'ir1_4TeV_settings_from_TWISS_20MeV_b1001_TRAKFILE', 2,1, kRed, 20, 'fluka incoming proton'], # 2,0 plots x:s  1,0 plots y:s]
        # [cpath + 'ir1_4TeV_settings_from_TWISS_20MeV_b1_MYM001_TRAKFILE', 2,1, kMagenta, 23, 'fluka outgoing aproton'], # 2,0 plots x:s  1,0 plots y:s
        # [cpath + 'ir1_4TeV_settings_from_TWISS_20MeV_b1001_TRAKFILE', 2,0, kRed, 20, 'fluka incoming proton'], # 2,0 plots x:s  1,0 plots y:s]
        # [cpath + 'ir1_4TeV_settings_from_TWISS_20MeV_b1_MYM001_TRAKFILE', 2,0, kMagenta, 23, 'fluka outgoing aproton'], # 2,0 plots x:s  1,0 plots y:s
        # [cpath + 'ir1_4TeV_settings_from_TWISS_20MeV_b1_MYM001_fort.89', 5,4, kBlack, 6, 'test size'], # 0cx 1cy 2cz 3x 4y 5z 6J 7A 
        # [cpath + 'ir1_4TeV_settings_from_TWISS_20MeV_b1_orbitDump001_fort.89', 5,4, kBlack, 6, 'test size'], # 0cx 1cy 2cz 3x 4y 5z 6J 7A 
        # [cpath + 'ir1_4TeV_settings_from_TWISS_20MeV_b1_orbitDump001_fort.89', 5,3, kBlack, 6, 'test size'], # 0cx 1cy 2cz 3x 4y 5z 6J 7A 
        # [cpath + 'BEAMGAS.dat', 2,1, kBlack, 6, 'input final BEAMGAS', '_yBEAMGAS', 'y cm'], # 0x 1y 2z 3u 4v 
        # [cpath + 'BEAMGAS.dat', 2,0, kBlack, 6, 'input final BEAMGAS', '_xBEAMGAS', 'x cm'], # 0x 1y 2z 3u 4v 
        # [cpath + 'startBG.dat', 2,1, kBlack, 6, 'input fluka startBG'], # 0x 1y 2z 3u 4v 
        # [cpath + 'startBG.dat', 2,0, kBlack, 6, 'input fluka startBG'], # 0x 1y 2z 3u 4v 
        # [cpath + 'THISISIT.dat', 5,4, kBlack, 6, 'input THISISIT', '_yTHISISIT', 'y cm'], # 0x 1y 2z 3u 4v 
        # [cpath + 'THISISIT.dat', 2,0, kBlack, 6, 'input THISISIT', '_xTHISISIT', 'x cm'], # 0x 1y 2z 3u 4v 
        # [cpath + 'BGAS10.dat', 2,1, kBlack, 6, 'input final BEAMGAS', '_yBGAS10', 'y cm'], # 0x 1y 2z 3u 4v 
        # [cpath + 'BGAS10.dat', 2,0, kBlack, 6, 'input final BEAMGAS', '_xBGAS10', 'x cm'], # 0x 1y 2z 3u 4v 
        # [cpath + 'BGAS.dat', 2,1, kBlack, 6, 'input final BEAMGAS', '_yBGAS', 'y cm'], # 0x 1y 2z 3u 4v repls
        #[cpath + 'awked_downselected_fort.89.10.cv53', 2,1, kBlack, 6, 'y-orbit at 6.5 TeV', '_yBGAS', 'y [cm]'], # 0x 1y 2z 3u 4v repls
        [cpath + 'awked_downselected_fort.89.10.cv53', 2,0, kBlack, 6, 'x-orbit at 6.5 TeV', '_xBGAS', 'x [cm]'], # 0x 1y 2z 3u 4v repls

       ]
    energy = "6.5 TeV"
    rel = ''
    ytitle = ''

    XurMin, XurMax = 150.,250. # zoom into badly increased beamsize region

    XurMin, XurMax = 20,80
    #XurMin, XurMax = -1, -1

    YurMin, YurMax = -10.5,-9.2 # zoom into badly increased beamsize region
    YurMin, YurMax = -0.5, 0.5
    #YurMin, YurMax = -0.02, 0.7
    #YurMin, YurMax = -1,-1

    cv = TCanvas( 'cv', 'cv', 1000, 600)

    x1, y1, x2, y2 = 0.34, 0.65, 0.9, 0.9
    mlegend = TLegend( x1, y1, x2, y2)
    mlegend.SetFillColor(0)
    mlegend.SetFillStyle(0)
    mlegend.SetLineColor(0)
    mlegend.SetTextSize(0.035)
    mlegend.SetShadowColor(0)
    mlegend.SetBorderSize(0)

    mg = TMultiGraph()
    # marker in legend
    lm = 'p'

    gr = []

    for fn,Xindex,Yindex,color,mStyle,lg,rel,ytitle in trakfiles:
        print 'opening', fn
        [S,Y] = helpers.getListFromColumn([Xindex,Yindex], fn)
        xList, yList = S,Y 
        xinmeter = [x*0.01 for x in xList]
        gr += [ makeTGraph(xinmeter, yList, color, mStyle) ]
        mlegend.AddEntry(gr[-1], lg, lm) 
        mg.Add(gr[-1])

    mg.Draw("a"+lm)
    mg.GetYaxis().SetTitle(ytitle)
    mg.GetXaxis().SetTitle('s [m]')
    if XurMin != -1:
        mg.GetXaxis().SetRangeUser(XurMin,XurMax)
        rel += 'ZoomX'
    if YurMin != -1:
        mg.GetYaxis().SetRangeUser(YurMin,YurMax)
        rel += 'ZoomY'

    #mlegend.Draw()
    lab = mylabel(42)
    lab.DrawLatex(0.45, 0.955,lg)

    cpath = '/afs/cern.ch/user/r/rkwee/public/www/HL-LHC/TCT/6.5TeV/beamgas/'
    pname = cpath + 'inputFluka6500GeV'+rel+'.root'
    pname = cpath + 'inputFluka6500GeV'+rel+'.pdf'

    print('Saving file as ' + pname ) 
    cv.Print(pname)

    pname = cpath + 'inputFluka6500GeV'+rel+'.png'
    print('Saving file as ' + pname ) 
    cv.Print(pname)
コード例 #8
0
def cv83():
    # ---------------------------------------------------
    rel = 'compallpint'
    #rel = 'compallpress'
    cv = TCanvas('cv' + rel, 'cv' + rel, 1500, 900)
    cv.SetLogy(1)
    cv.SetGridy(0)
    x1, y1, x2, y2 = 0.67, 0.72, 0.88, 0.92
    mlegend = TLegend(x1, y1, x2, y2)
    mlegend.SetFillColor(0)
    mlegend.SetFillStyle(0)
    mlegend.SetLineColor(0)
    mlegend.SetTextSize(0.035)
    mlegend.SetShadowColor(0)
    mlegend.SetBorderSize(0)

    mg = TMultiGraph(rel, rel)
    lm = 'l'

    grs = []

    for i, (pFile, xTitle, lText) in enumerate(pData):

        print "." * 33
        print "Getting data from file", pFile

        data = {}
        if pFile.count("2736"):
            data = cv32.getdata14c(pFile)
            stmp, rho_C, rho_H, rho_O = cv65.getAtomicRho(data)
            stmp2 = stmp[1:]
            s_full = stmp2[::-1]
            pint_C, pint_H, pint_O, pint_tot = cv65.calc_pint_tot(
                rho_C, rho_H, rho_O)
            totalPress = [
                data['H2_N2Eq'][j] + data['CH4_N2Eq'][j] + data['CO_N2Eq'][j] +
                data['CO2_N2Eq'][j] for j in range(len(data['H2_N2Eq']))
            ]
        elif pFile.count("Density_Fill4"):
            data = cv79.getdata5c(pFile)
            totalPress = cv79.getTotalPressure(data)
            rho_H2, rho_CH4, rho_CO, rho_CO2 = cv79.getrho(
                data['H2_Eq']), cv79.getrho(data['CH4_Eq']), cv79.getrho(
                    data['CO_Eq']), cv79.getrho(data['CO2_Eq'])
            rho_H, rho_C, rho_O = cv79.getAtomicRho(rho_H2, rho_CH4, rho_CO,
                                                    rho_CO2)
            pint_H, pint_C, pint_O, pint_tot = cv79.getpint(
                rho_H, rho_C, rho_O)
            s_full = data['s']
        elif pFile.count("HL_LHC"):
            # will only work for pint
            data = cv95.getdata14cHL(pFile)

            rho_H2 = cv79.getrho(data['H2_N2Eq'])
            rho_CH4 = cv79.getrho(data['CH4_N2Eq'])
            rho_CO2 = cv79.getrho(data['CO2_N2Eq'])
            rho_CO = cv79.getrho(data['CO_N2Eq'])

            rho_H, rho_C, rho_O = cv79.getAtomicRho(rho_H2, rho_CH4, rho_CO,
                                                    rho_CO2)
            pint_H, pint_C, pint_O, pint_tot = cv79.getpint(
                rho_H, rho_C, rho_O)
            stmp = data["s"]
            s_full = list(reversed(list(
                reversed(stmp))))  # list last element of reversed list first

        s_incoming = []

        pint_incoming, pint_tot_incomingbeam = [], []

        # only one side, chose positive s
        s_positiveb1, s_positiveb2 = [], []

        #print s_full
        for cs in s_full:
            s = float(cs)
            if s < 0.:
                s_positiveb1 += [-s]
            else:
                s_positiveb2 += [s]

        print "len(s_positiveb1)", len(s_positiveb1)
        print "len(s_positiveb2)", len(s_positiveb2)

        if lText.count("B2"):
            pint_tot_incomingbeam = pint_tot[len(s_positiveb2):]
            press_tot_incomingbeam = totalPress[len(s_positiveb2):]
            s_incoming = s_positiveb2[:len(s_positiveb2) - 1]
        else:
            pint_tot_incomingbeam = [
                p for p in pint_tot[:len(s_positiveb1) + 1]
            ]
            if not pFile.count("HL_LHC"):
                press_tot_incomingbeam = [
                    p for p in totalPress[:len(s_positiveb1) + 1]
                ]
            s_incoming = s_positiveb1
            if pFile.count("2736"):
                pint_tot_incomingbeam = pint_tot_incomingbeam[::-1]
                press_tot_incomingbeam = totalPress[::-1]

        print "len(pint_tot_incomingbeam)", len(pint_tot_incomingbeam)
        print "len(s_incoming)", len(s_incoming)

        print i, cols
        #        print s_incoming[:100],press_tot_incomingbeam[:100]
        xlist, ylist, col, mstyle, lg = s_incoming, pint_tot_incomingbeam, cols[
            i], 20 + i, lText
        #xlist, ylist, col, mstyle, lg = s_incoming,press_tot_incomingbeam , cols[i],20+i, lText
        grs += [makeTGraph(xlist, ylist, col, mstyle)]
        mlegend.AddEntry(grs[-1], lg, lm)
        mg.Add(grs[-1])

    mg.Draw("al")
    Tt = TLatex()
    Tt = "#splitline{interaction probability density}{[1/proton/m/s]}"
    #mg.SetTitle("pressure profiles")
    mg.GetXaxis().SetTitle(xTitle)
    mg.GetYaxis().SetTitle(Tt)
    #mg.GetYaxis().SetTitle("total pressure [mbar]")
    mg.GetYaxis().SetRangeUser(5e-18, 4e-10)
    #mg.GetYaxis().SetRangeUser(5e-13,4e-6)
    mg.GetXaxis().SetRangeUser(0, 260)
    mlegend.Draw()
    lab = mylabel(42)
    lab.DrawLatex(0.42, 0.82, 'incoming beams')

    s = 22.6
    lInterface = TLine()
    lInterface.SetLineStyle(2)
    lInterface.SetLineColor(kGray + 3)
    YurMin, YurMax = 5e-18, 4e-10
    lInterface.DrawLine(s, YurMin, s, YurMax)
    pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/6500GeV/reweighted/'
    pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/HLRunII/'

    pname = '/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLLHCBackgroundPaper/figures/'
    pname += rel + ".pdf"
    print('Saving file as ' + pname)
    cv.Print(pname)
コード例 #9
0
ファイル: cv65.py プロジェクト: regkwee/LHC-Collimation
def cv65():
    # --------------------------------------------------------------------------------
    # density profile is given in the following format:
    # densities per molecule as function of s-coordinate
    # x,y,z, cx, cy, cz as function of (different s-coordinate)
    # merge densities with coordinates
    # note, that the source routine needs fluka units, ie *cm*!
    # --------------------------------------------------------------------------------
    bgfile = '/afs/cern.ch/work/r/rkwee/HL-LHC/beam-gas-sixtrack/pressure_profiles_2012/LSS1_B1_Fill2736_Final.csv'
    bgfile = '/Users/rkwee/Documents/RHUL/work/data/4TeV/LSS1_B1_Fill2736_Final.csv'

    data = getdata14c(bgfile)
    print 'data keys are', data.keys()

    # --
    s, rho_C, rho_H, rho_O = getAtomicRho(data)

    # plot atomic densities

    cv = TCanvas('cv', 'cv', 2100, 900)

    x1, y1, x2, y2 = 0.8, 0.7, 0.9, 0.92
    mlegend = TLegend(x1, y1, x2, y2)
    mlegend.SetFillColor(0)
    mlegend.SetFillStyle(0)
    mlegend.SetLineColor(0)
    mlegend.SetTextSize(0.035)
    mlegend.SetShadowColor(0)
    mlegend.SetBorderSize(0)

    mg = TMultiGraph()
    lm = 'pl'

    pint_C, pint_H, pint_O, pint_tot = calc_pint_tot(rho_C, rho_H, rho_O)

    xlist, ylist, col, mstyle, lg = s[1:], pint_tot, kBlack, 28, 'total'
    g3 = makeTGraph(xlist, ylist, col, mstyle)
    mlegend.AddEntry(g3, lg, lm)
    mg.Add(g3)

    xlist, ylist, col, mstyle, lg = s[1:], pint_O, kGreen, 22, 'O'
    g0 = makeTGraph(xlist, ylist, col, mstyle)
    mlegend.AddEntry(g0, lg, lm)
    mg.Add(g0)

    xlist, ylist, col, mstyle, lg = s[1:], pint_C, kGreen - 1, 20, 'C'
    g1 = makeTGraph(xlist, ylist, col, mstyle)
    mlegend.AddEntry(g1, lg, lm)
    mg.Add(g1)

    xlist, ylist, col, mstyle, lg = s[1:], pint_H, kBlue - 2, 23, 'H'
    g2 = makeTGraph(xlist, ylist, col, mstyle)
    mlegend.AddEntry(g2, lg, lm)
    mg.Add(g2)

    mg.Draw("alp")

    gPad.SetLogy(1)
    gPad.RedrawAxis()

    lab = mylabel(42)
    lab.DrawLatex(0.45, 0.88, 'interaction probability')

    mg.SetTitle("pressure profiles")
    mg.GetXaxis().SetTitle('distance to IP1 [m]')
    mg.GetYaxis().SetTitle('interaction probability [1/proton/m/s]'
                           )  #"density #rho [atoms/m^{3}]")
    mg.GetYaxis().SetRangeUser(7e-17, 9e-11)
    mlegend.Draw()

    pname = wwwpath + 'TCT/beamgas/pressure_profiles_2012/pint.pdf'
    pname = "/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/4TeV/reweighted/cv65_pint.pdf"

    pname = "/Users/rkwee/Documents/RHUL/work/HL-LHC/LHC-Collimation/Documentation/ATS/HLHaloBackgroundNote/figures/4TeV/reweighted/cv65_pint_2011.pdf"
    print('Saving file as ' + pname)
    cv.Print(pname)
コード例 #10
0
def cv39():

    gamma_rel = 4.e3 / 0.938
    energy = '4TeV'

    # twiss file
    # tf = pymadx.Tfs('/afs/cern.ch/work/r/rkwee/HL-LHC/LHC-Collimation/SixTrackConfig/6.5TeV/MED800/B1/twiss_lhcb1_med_new_thin_800.tfs')
    # tf = pymadx.Tfs('/afs/cern.ch/work/r/rkwee/HL-LHC/LHC-Collimation/SixTrackConfig/6.5TeV/MED800/B1/1cm/twiss_lhcb1_med_new_thin_800_1cm.tfs')
    # tf = pymadx.Tfs("/afs/cern.ch/work/r/rkwee/HL-LHC/LHC-Collimation/SixTrackConfig/4TeV/beamgas/twiss_4tev_b1.data")
    tf = pymadx.Tfs(
        "/afs/cern.ch/work/r/rkwee/HL-LHC/LHC-Collimation/SixTrackConfig/6.5TeV/background_2015_80cm/MADX_2015/twiss_b2.tfs"
    )
    gamma_rel = 6.5e3 / 0.938
    energy = "6.5TeV"

    BETX = tf.GetColumn('BETX')
    BETY = tf.GetColumn('BETY')
    ALFX = tf.GetColumn('ALFX')
    ALFY = tf.GetColumn('ALFY')
    X = tf.GetColumn('X')
    Y = tf.GetColumn('Y')
    PX = tf.GetColumn('PX')
    PY = tf.GetColumn('PY')
    S = tf.GetColumn('S')
    IP5 = tf.GetColumnDict('S')['IP5']
    IP8 = tf.GetColumnDict('S')['IP8']

    # no shift if val is length
    shiftVal = length_LHC  #-500

    cnt = 0

    S_shifted, X_shifted = [], []
    for s in S:
        s_shifted = s + shiftVal
        #print "s_shifted", s_shifted

        if s_shifted >= length_LHC:
            cnt += 1
            s_shifted -= length_LHC
            #print "s_shifted after subtraction", s_shifted

        S_shifted += [s_shifted]
        #print "using", s_shifted

    S_shifted.sort()
    lShift = 0.5

    XurMin, XurMax = 0, 548.
    XurMin, XurMax = -1, -1
    XurMin, XurMax = length_LHC - 500, length_LHC
    # rel = '_sigma_IR1Right_1cm'
    # rel = '_sigma_IR1Left_'+energy
    rel = 'from_twiss_orbit_IR1'
    # lShift = 0.0

    # XurMin, XurMax = IP5-300, IP5+300
    # rel = '_IP5'
    # XurMin, XurMax = IP8-300, IP8+300
    # rel = '_IP8'

    cv = TCanvas('cv', 'cv', 2100, 900)

    x1, y1, x2, y2 = 0.8 - lShift, 0.65, 0.9 - lShift, 0.9
    mlegend = TLegend(x1, y1, x2, y2)
    mlegend.SetFillColor(0)
    mlegend.SetFillStyle(0)
    mlegend.SetLineColor(0)
    mlegend.SetTextSize(0.05)
    mlegend.SetShadowColor(0)
    mlegend.SetBorderSize(0)

    mg = TMultiGraph()
    # marker in legend
    lm = 'l'

    emittance_norm = 3.5e-6
    emittance_geo = emittance_norm / gamma_rel

    SIGX = [math.sqrt(betax * emittance_geo) for betax in BETX]
    SIGY = [math.sqrt(betay * emittance_geo) for betay in BETY]

    # xList, yList, color, mStyle, lg = S_shifted, SIGX, kGreen-1, 22, '#sigma_{x}'
    # g0 = makeTGraph(xList, yList, color, mStyle)
    # mlegend.AddEntry(g0, lg, lm)
    # mg.Add(g0)
    # xList, yList, color, mStyle, lg = S_shifted, SIGY, kGreen-2, 20, '#sigma_{y}'
    # g1 = makeTGraph(xList, yList, color, mStyle)
    # mlegend.AddEntry(g1, lg, lm)
    # mg.Add(g1)
    ytitle = 'beam size [m]'

    xList, yList, color, mStyle, lg = S_shifted, X, kGreen + 1, 21, "x [m]"
    g1 = makeTGraph(xList, yList, color, mStyle)
    mlegend.AddEntry(g1, lg, lm)
    mg.Add(g1)

    xList, yList, color, mStyle, lg = S_shifted, Y, kBlue - 1, 20, "y [m]"
    g2 = makeTGraph(xList, yList, color, mStyle)
    mlegend.AddEntry(g2, lg, lm)
    mg.Add(g2)
    ytitle = 'orbit'

    # xList, yList, color, mStyle, lg = S_shifted, PY, kBlue+1, 27, "y'"
    # g3 = makeTGraph(xList, yList, color, mStyle)
    # mlegend.AddEntry(g3, lg, lm)
    # mg.Add(g3)

    mg.Draw("a" + lm)

    l = TLine()
    l.SetLineStyle(1)
    YurMin, YurMax = 0, 0.0019
    l.SetLineColor(kRed)

    # s = 22.6
    # l.DrawLine(s,YurMin,s,YurMax)

    # s = 59.
    # l.DrawLine(s,YurMin,s,YurMax)

    # s = 153.
    # l.DrawLine(s,YurMin,s,YurMax)

    # s = 269.
    # l.DrawLine(s,YurMin,s,YurMax)

    mg.GetYaxis().SetTitle(ytitle)
    mg.GetXaxis().SetTitle('s [m]')
    if XurMin != -1:
        mg.GetXaxis().SetRangeUser(XurMin, XurMax)

    mlegend.Draw()

    pname = wwwpath
    subfolder = 'TCT/' + energy + '/beamgas/'
    pname += subfolder + ytitle + '_' + rel.replace(".", "p") + '.pdf'

    print('Saving file as ' + pname)
    cv.Print(pname)

    pname = wwwpath
    subfolder = 'TCT/' + energy + '/beamgas/'
    pname += subfolder + 'from_twiss_' + rel.replace(".", "p") + '.png'

    print('Saving file as ' + pname)
    cv.Print(pname)