Exemplo n.º 1
0
def main():
    gROOT.Reset()
    for fill in fills:
	print "Processing fill", fill
	file = csvFilePattern.replace('__XXX__', str(fill))
	rootFile = rootFilePattern.replace('__XXX__', str(fill))
	
	try:
	    fin = open(file, 'r')
	except IOError:
	    print "Cannot open file", file
	    continue
		
	try:
	    fout = TFile(rootFile,'RECREATE')
	except IOError:
	    print "Cannot open file for output", rootFile
	    continue	 

	t = TTree('t', 'Fill CSV data')
	lumiData = LumiData()
	t.Branch('numBranch',  lumiData, 'fill/D:run/D:lsno/D:nb4/D:secs/D:secsUtc/D:msecs/D:deadfrac/D:primaryLumi/D:hf/D:hfRaw/d:plt/D:pltRaw/D:pltZero/D:pltZeroRaw/D:bcmf/D:bcmfRaw/D')

	first = 1 # to skip the header
	
	for line in fin.readlines():
	    #Skip header
	    if first:
		first = 0
		continue
	    
	    data = line.split(',')
	    
	    lumiData.fill = float(data[0].replace('FILL', ''))
	    lumiData.run = float(data[1])
	    lumiData.lsno = float(data[2])
	    lumiData.nb4 = float(data[3])
	    lumiData.secs = float(data[5])
	    lumiData.secsUtc = float(local2utc(int(data[5])))
	    lumiData.msecs = float(data[6])
	    lumiData.deadfrac = float(data[7])
	    lumiData.primaryLumi = float(data[9])
	    lumiData.hf = float(data[10])
	    lumiData.hfRaw = float(data[11])
	    lumiData.plt = float(data[12])
	    lumiData.pltRaw = float(data[3])
	    lumiData.pltZero = float(data[14])
	    lumiData.pltZeroRaw = float(data[15])
	    lumiData.bcmf = float(data[16])
	    lumiData.bcmfRaw = float(data[17])

	    t.Fill()
	    del data
	del fin

	print "Writing", rootFile
	fout.Write()
	fout.Close()
	del fout
Exemplo n.º 2
0
    def writeOutput(self):

        rootFile = radmonLumiFilePattern.replace('__XXX__', str(self.fill))
        try:
            fout = TFile(rootFile, 'RECREATE')
        except IOError:
            print "Cannot open file for output", rootFile
            exit

        t = TTree('t', 'Combined Lumi and Radmon data')

        timingData = TimingData()
        lumiData = LumiData()
        radmonData = RadmonData()
        t.Branch('timingBranch', timingData,
                 'fill/D:startFill/D:endFill/D:run/D:lsno/D:tsUtc/D')
        t.Branch(
            'lumiBranch', lumiData,
            'primaryLumi/D:primaryLumiErr/D:hf/D:hfErr/D:plt/D:pltErr/D:pltZero/D:pltZeroErr/D:bcmf/D:bcmfErr/D'
        )
        t.Branch('radmonBranch', radmonData, 'rates[16]/D:ratesErr[16]/D')

        href = self.pprlumi  # Reference histogram
        #self.pbcmf.Draw()
        #raw_input("Press enter to continue")
        for i in range(len(self.xx) - 1):
            timingData.fill = self.td[i].fill
            timingData.startFill = self.td[i].startFill
            timingData.endFill = self.td[i].endFill
            timingData.run = self.td[i].run
            timingData.lsno = self.td[i].lsno
            timingData.tsUtc = href.GetXaxis().GetBinCenter(i)

            lumiData.primaryLumi = self.pprlumi.GetBinContent(i)
            lumiData.primaryLumiErr = self.pprlumi.GetBinError(i)
            lumiData.hf = self.phf.GetBinContent(i)
            lumiData.hfErr = self.phf.GetBinError(i)
            lumiData.plt = self.pplt.GetBinContent(i)
            lumiData.pltErr = self.pplt.GetBinError(i)
            lumiData.pltZero = self.ppltZero.GetBinContent(i)
            lumiData.pltZeroErr = self.ppltZero.GetBinError(i)
            lumiData.bcmf = self.pbcmf.GetBinContent(i)
            lumiData.bcmfErr = self.pbcmf.GetBinError(i)

            for j in range(len(self.pradmon)):
                radmonData.rates[j] = self.pradmon[j].GetBinContent(i)
                radmonData.ratesErr[j] = self.pradmon[j].GetBinError(i)

            t.Fill()
        print "Writing", rootFile
        fout.Write()
        fout.Close()
        del fout
Exemplo n.º 3
0
    def writeOutput(self):
	
	rootFile = radmonLumiFilePattern.replace('__XXX__', str(self.fill))
	try:
	    fout = TFile(rootFile,'RECREATE')
	except IOError:
	    print "Cannot open file for output", rootFile
	    exit	 

	t = TTree('t', 'Combined Lumi and Radmon data')
	
	timingData = TimingData()
	lumiData = LumiData()
	radmonData = RadmonData()
	t.Branch('timingBranch',  timingData, 'fill/D:startFill/D:endFill/D:run/D:lsno/D:tsUtc/D')
	t.Branch('lumiBranch',  lumiData, 'primaryLumi/D:primaryLumiErr/D:hf/D:hfErr/D:plt/D:pltErr/D:pltZero/D:pltZeroErr/D:bcmf/D:bcmfErr/D')
    	t.Branch('radmonBranch',  radmonData, 'rates[16]/D:ratesErr[16]/D')
    	
    	href = self.pprlumi  # Reference histogram
	#self.pbcmf.Draw()
	#raw_input("Press enter to continue")
    	for i in range(len(self.xx) - 1):
	    timingData.fill = self.td[i].fill
	    timingData.startFill = self.td[i].startFill
	    timingData.endFill = self.td[i].endFill
	    timingData.run = self.td[i].run
	    timingData.lsno = self.td[i].lsno
	    timingData.tsUtc = href.GetXaxis().GetBinCenter(i)
	    
	    lumiData.primaryLumi = self.pprlumi.GetBinContent(i)
	    lumiData.primaryLumiErr = self.pprlumi.GetBinError(i)
	    lumiData.hf = self.phf.GetBinContent(i)
	    lumiData.hfErr = self.phf.GetBinError(i)
	    lumiData.plt = self.pplt.GetBinContent(i)
	    lumiData.pltErr = self.pplt.GetBinError(i)
	    lumiData.pltZero = self.ppltZero.GetBinContent(i)
	    lumiData.pltZeroErr = self.ppltZero.GetBinError(i)
	    lumiData.bcmf = self.pbcmf.GetBinContent(i)
	    lumiData.bcmfErr = self.pbcmf.GetBinError(i)
	    
	    for j in range(len(self.pradmon)):
		radmonData.rates[j] = self.pradmon[j].GetBinContent(i)
		radmonData.ratesErr[j] = self.pradmon[j].GetBinError(i)

	    t.Fill()
	print "Writing", rootFile
	fout.Write()
	fout.Close()
	del fout
Exemplo n.º 4
0
def main():
    gROOT.Reset()
    for fill in fills:
        print "Processing fill", fill
        file = csvFilePattern.replace('__XXX__', str(fill))
        rootFile = rootFilePattern.replace('__XXX__', str(fill))

        try:
            fin = open(file, 'r')
        except IOError:
            print "Cannot open file", file
            continue

        try:
            fout = TFile(rootFile, 'RECREATE')
        except IOError:
            print "Cannot open file for output", rootFile
            continue

        t = TTree('t', 'Fill CSV data')
        lumiData = LumiData()
        t.Branch(
            'numBranch', lumiData,
            'fill/D:run/D:lsno/D:nb4/D:secs/D:secsUtc/D:msecs/D:deadfrac/D:primaryLumi/D:hf/D:hfRaw/d:plt/D:pltRaw/D:pltZero/D:pltZeroRaw/D:bcmf/D:bcmfRaw/D'
        )

        first = 1  # to skip the header

        for line in fin.readlines():
            #Skip header
            if first:
                first = 0
                continue

            data = line.split(',')

            lumiData.fill = float(data[0].replace('FILL', ''))
            lumiData.run = float(data[1])
            lumiData.lsno = float(data[2])
            lumiData.nb4 = float(data[3])
            lumiData.secs = float(data[5])
            lumiData.secsUtc = float(local2utc(int(data[5])))
            lumiData.msecs = float(data[6])
            lumiData.deadfrac = float(data[7])
            lumiData.primaryLumi = float(data[9])
            lumiData.hf = float(data[10])
            lumiData.hfRaw = float(data[11])
            lumiData.plt = float(data[12])
            lumiData.pltRaw = float(data[3])
            lumiData.pltZero = float(data[14])
            lumiData.pltZeroRaw = float(data[15])
            lumiData.bcmf = float(data[16])
            lumiData.bcmfRaw = float(data[17])

            t.Fill()
            del data
        del fin

        print "Writing", rootFile
        fout.Write()
        fout.Close()
        del fout