コード例 #1
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
コード例 #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
コード例 #3
0
    def setupRanges(self):
        """
	read file with lumi data 
	setup low edges of histograms corresponding to the beginning of lumisections
	fill array of timing  structures (fill, ls, run) corresponding to the given bin
	"""
        startOfFill = -1
        lsection = -1

        timingData = TimingData()

        f = TFile(lumiFilePattern.replace('__XXX__', str(self.fill)))
        tree = f.Get("t")

        for i in range(0, tree.GetEntries()):
            nb = tree.GetEntry(i)
            if nb < 0:
                continue

            #Y range for histograms
            if tree.primaryLumi > self.yMax:
                self.yMax = tree.primaryLumi
            if tree.primaryLumi < self.yMin:
                self.yMin = tree.primaryLumi

            #Setting start/end of the fill
            if tree.secsUtc < self.fromto[0]:
                self.fromto[0] = tree.secsUtc
            if tree.secsUtc > self.fromto[1]:
                self.fromto[1] = tree.secsUtc

            #Low edges for histos (start of LS)
            if tree.lsno != lsection:
                self.xx.append(tree.secsUtc + tree.msecs / 1000.)
                lsection = tree.lsno
                # New lumisection - fill timing data
                timingData.fill = tree.fill
                timingData.run = tree.run
                timingData.lsno = tree.lsno
                timingData.endFill = tree.secsUtc + tree.msecs / 1000.
                if startOfFill < 0:
                    timingData.startFill = tree.secsUtc + tree.msecs / 1000.
                    startOfFill = timingData.startFill

                self.td.append(timingData)

        del tree
        del f
コード例 #4
0
    def setupRanges(self):
	"""
	read file with lumi data 
	setup low edges of histograms corresponding to the beginning of lumisections
	fill array of timing  structures (fill, ls, run) corresponding to the given bin
	"""
	startOfFill = -1
	lsection = -1
	
	timingData = TimingData()
	
	f = TFile(lumiFilePattern.replace('__XXX__', str(self.fill)))
	tree = f.Get("t")
	
	for i in range(0, tree.GetEntries()) :
	    nb = tree.GetEntry(i)
	    if nb < 0:
		continue

	    #Y range for histograms
	    if tree.primaryLumi > self.yMax:
		 self.yMax = tree.primaryLumi
	    if tree.primaryLumi < self.yMin:
		 self.yMin = tree.primaryLumi
		
	    #Setting start/end of the fill
	    if  tree.secsUtc < self.fromto[0]:
		self.fromto[0] = tree.secsUtc
	    if tree.secsUtc > self.fromto[1]:
		self.fromto[1] = tree.secsUtc

	    #Low edges for histos (start of LS)
	    if tree.lsno != lsection:
		self.xx.append(tree.secsUtc + tree.msecs/1000.)
		lsection = tree.lsno
		# New lumisection - fill timing data
		timingData.fill = tree.fill
		timingData.run = tree.run
		timingData.lsno = tree.lsno
		timingData.endFill = tree.secsUtc  + tree.msecs/1000.
		if startOfFill < 0:
		    timingData.startFill = tree.secsUtc  + tree.msecs/1000.
		    startOfFill = timingData.startFill
	    
		self.td.append(timingData)
	    
	del tree
	del f