def readFBCT(file_fbct, fill):
    c = f.LHCFills(fill)

    beginTime = c.Begin()
    stableTime = c.Stable()
    endTime = c.End()
    plotTitle = c.Title()

    fbct = []
    gr = TGraph()
    reader = csv.reader(open(file_fbct, 'rb'))

    bxs = [1, 2, 3, 4]
    i = 0
    for row in reader:
        myDateTime = datetime.strptime(row[0], "%Y-%m-%d %H:%M:%S.%f")
        dt = TDatime(int(myDateTime.year), int(myDateTime.month),
                     int(myDateTime.day), int(myDateTime.hour),
                     int(myDateTime.minute), int(myDateTime.second))
        daTime = dt.Convert()
        ddd = float(dt.Convert() - beginTime.Convert())
        for bx in bxs:
            gr.SetPoint(i, ddd, float(row[1]))
        i += 1

    return gr
def readTIMBER_BX_INT(
    fill,
    BX='1',
    source="ATLAS",
    datatype='B1_INT_MEAN',
):
    # source and datatype: see comment for readTIMBER_TOT_INT()
    if fill == 0: fill = 4381
    file_data = "../DATA/TIMBER-FILL-" + str(
        fill) + "/TIMBER_" + source + "." + datatype + ".csv"

    print " ... reading TIMBER data file", file_data

    c = f.LHCFills(fill)
    beginTime = c.Begin()

    gr = TGraph()
    try:
        reader = csv.reader(open(file_data, 'rb'))
    except IOError:
        return gr

    scale = 1E-11
    if 'LEN' in file_data: scale = 1
    skiplines = 10
    i = 0
    for row in reader:
        i += 1
        if i <= skiplines: continue
        # if i<20: print len(row)

        try:
            myDateTime = datetime.strptime(row[0], "%Y-%m-%d %H:%M:%S.%f")
        except IndexError:
            print 'Index Error in ', row
            print 'But will continue'
            continue
        dt = TDatime(int(myDateTime.year), int(myDateTime.month),
                     int(myDateTime.day), int(myDateTime.hour),
                     int(myDateTime.minute), int(myDateTime.second))
        daTime = dt.Convert()
        ddd = float(dt.Convert() - beginTime.Convert())
        # print i, BX, row[0], row[int(BX)]

        # gr.SetPoint(i-6,ddd, float(1))
        gr.SetPoint(i - skiplines, ddd, scale * float(row[int(BX)]))

    return gr
def readTIMBER_TOT_INT(
    fill,
    source="ATLAS",
    datatype='B1_INT_MEAN',
):
    # source = ATLAS, BCTDC.A6R4, BCTFR.A6R4
    # datatype = B1 or2 _INT_ MEAN or SUM (this is hardcoded in the names of the .csv files)
    file_data = "../DATA/TIMBER-FILL-" + str(
        fill) + "/TIMBER_" + source + "." + datatype + ".csv"

    print " ... reading TIMBER data file", file_data

    c = f.LHCFills(fill)
    beginTime = c.Begin()

    gr = TGraph()
    try:
        reader = csv.reader(open(file_data, 'rb'))
    except IOError:
        return gr

    skiplines = 10
    i = 0
    for row in reader:
        i += 1
        if i <= skiplines: continue

        try:
            myDateTime = datetime.strptime(row[0], "%Y-%m-%d %H:%M:%S.%f")
        except ValueError:
            print i, 'Bad format:', row[0]
            print 'But we will continue'
            continue
            #exit(0)

        dt = TDatime(int(myDateTime.year), int(myDateTime.month),
                     int(myDateTime.day), int(myDateTime.hour),
                     int(myDateTime.minute), int(myDateTime.second))
        daTime = dt.Convert()
        ddd = float(dt.Convert() - beginTime.Convert())
        # print i, row[0], row[1]

        #if source==''
        gr.SetPoint(i - skiplines, ddd, 1E-11 * float(row[1]))

    return gr
Exemple #4
0
                  help="Draw ATLAS BPTX data from TIMBER")
parser.add_option("--cms",
                  dest="cms",
                  action="store_true",
                  default=False,
                  help="Draw CMS data instead of FBCT (sanity check)")

(opt, args) = parser.parse_args()
if len(args) < 1:
    print '\t ERROR. Provide the Fill number, like: plot_bunches.py 1234'
    parser.print_usage()
    exit(1)

fillNumber = sys.argv[1]
if fillNumber == "0":
    c = f.LHCFills(0, TDatime(2015, 9, 17, 2, 10, 00), None,
                   TDatime(2015, 9, 17, 2, 15, 00))
    TimeFormat = "%H:%M"
    # For the whole history plots. Hmmm.. the bunches are not made for this.
    #c = f.LHCFills(0, TDatime(2015,5,1,1,00,00), None, TDatime(2015,12,15,1,00,00))
    #TimeFormat ="%d %b"
else:
    c = f.LHCFills(fillNumber)
    TimeFormat = "%H:%M"

# This will over-write the Times above:
#c = f.LHCFills(4565)


def createDir(myDir):
    if not os.path.exists(myDir):
        try:
Exemple #5
0
#! /usr/bin/python

import sys
sys.argv.append('-b')

from array import *
from ROOT import *
import fill_class as f

c = f.LHCFills(2466)

c.Begin().Print()
fill = c.Fill()
beginTime = c.Begin()
stableTime = c.Stable()
endTime = c.End()
plotTitle = c.Title()

path = "../DATA/"

chain = TChain("cogTree")
chain.Add(path + "root/bptx_mon_cogging_2011_12_05_UTC.root")
chain.Add(path + "root/bptx_mon_cogging_2011_12_06_UTC.root")

nBunches = 354
b1_bunches = array('i', 400 * [0])
b2_bunches = array('i', 400 * [0])
chain.SetBranchAddress("b1_bunches", b1_bunches)
chain.SetBranchAddress("b2_bunches", b2_bunches)
chain.GetEntry(100)
b1_bunches = sorted(list(set(b1_bunches).difference(set([0]))))
Exemple #6
0
#! /usr/bin/python

import sys
sys.argv.append('-b')

import csv
from ROOT import *
from datetime import datetime

import fill_class as f

c = f.LHCFills(2318)

path = "/home/andreypz/Dropbox/BPTXmon_data/"
file_atl = "timber_deltaT_atlas_" + str(c.Fill()) + ".csv"
file_cms = "timber_deltaT_cms_" + str(c.Fill()) + ".csv"

print c.Fill(), c.Title()
c.Begin().Print()
print c.Begin().GetDay()
fill = c.Fill()
plotTitle = ';'

beginTime = c.Begin()
stableTime = c.Stable()
endTime = c.End()
plotTitle = c.Title()

reader_atl = csv.reader(open(file_atl, 'rb'))
reader_cms = csv.reader(open(file_cms, 'rb'))
gr_atl = TGraph()
#! /usr/bin/python

import sys
sys.argv.append('-b')

from array import *
from ROOT import *
import fill_class as f

c = f.LHCFills(2469)

c.Begin().Print()
fill = c.Fill()
beginTime = c.Begin()
stableTime = c.Stable()
endTime = c.End()
plotTitle = c.Title()

chain = TChain("cogTree")
#chain.Add("root/bptx_mon_cogging_2012_04_04_UTC.root")
#chain.Add("root/bptx_mon_cogging_2012_04_05_UTC.root")
#chain.Add("root/bptx_mon_cogging_2012_04_06_UTC.root")
#chain.Add("root/bptx_mon_cogging_2011_12_05_UTC.root")
#chain.Add("root/bptx_mon_cogging_2011_12_06_UTC.root")

gROOT.ProcessLine(".L /home/andreypz/Documents/0work/tdrstyle.C")
setTDRStyle()
gStyle.SetTimeOffset(beginTime.Convert())
gStyle.SetLabelSize(0.03, "X")
gStyle.SetLabelOffset(0.02, "X")
begin = str(beginTime.Convert())
        # gr.SetPoint(i-6,ddd, float(1))
        gr.SetPoint(i - skiplines, ddd, scale * float(row[int(BX)]))

    return gr


if __name__ == "__main__":

    gROOT.ProcessLine(".L ~/tdrstyle.C")
    setTDRStyle()

    myFILL = 4381
    outDir = './timber-plots/fill_' + str(myFILL)
    createDir(outDir)

    c = f.LHCFills(myFILL)
    beginTime = c.Begin()
    endTime = c.End()
    print c.Fill(), c.Title()
    c.Begin().Print()
    print c.Begin().GetDay()
    plotTitle = ';'

    gStyle.SetTimeOffset(beginTime.Convert())
    duration = endTime.Convert() - beginTime.Convert()

    # file_fbct = "timber_FBCT_"+str(c.Fill())+".csv"
    #readFBCT(file_fbct)
    atl = readATLASint(4381)

    atl.GetXaxis().SetTimeDisplay(1)
Exemple #9
0
                  help="Draw a line for Stable Beams start")

(options, args) = parser.parse_args()
if len(args) < 1:
    parser.print_usage()
    exit(1)

drawSB = options.drawSB

fillNumber = args[0]

if fillNumber == "0":
    #c = f.LHCFills(0, TDatime(2015,7,14,4,10,00), None, TDatime(2015,7,14,11,10,00))
    #TimeFormat ="%H:%M"
    # For the whole history plots.
    c = f.LHCFills(0, TDatime(2016, 3, 29, 9, 00, 00), None,
                   TDatime(2016, 10, 23, 23, 00, 00))
    TimeFormat = "%d %b"
    #TimeFormat ="%H %M"
else:
    c = f.LHCFills(fillNumber)
    TimeFormat = "%H:%M"

fill = c.Fill()
plotTitle = ';'

beginTime = c.Begin()
if (c.Stable() != None):
    stableTime = c.Stable()
else:
    stableTime = c.Begin()
endTime = c.End()