Example #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')
	
	fillData = FillData()
	lumiData = LumiData()
	radmonData = RadmonData()
	
	t.Branch('fillBranch', fillData, 'fill/I:fillStart/I:fillStable/I:fillEnd/I:durationStable/I:run/I:lsNo/I:tstamp/I:msecs/I:bunchSpacing/I')
	t.Branch('fillBranchD', AddressOf(fillData, 'bField'), 'bField/D:beamEnergy/D')
	t.Branch('lumiBranch',  lumiData, 'bestLumi/D:bestLumiErr/D:hfLumi/D:hfLumiErr/D:pltLumi/D:pltLumiErr/D:pltZeroLumi/D:pltZeroLumiErr/D:bcmfLumi/D:bcmfLumiErr/D')
    	t.Branch('radmonBranch',  radmonData, 'rates[16]/D:ratesErr[16]/D')
    	
    	href = self.pbest  # Reference histogram
	#self.pbcmf.Draw()
	#raw_input("Press enter to continue")
	
        print "Starting filling tree, file ", radmonLumiFilePattern.replace('__XXX__', str(self.fill))
    	for i in range(len(self.xx) - 1):
            fillData.fill = self.fillDataList[i].fill
            fillData.fillStart =  self.fillDataList[i].fillStart
            fillData.fillStable =  self.fillDataList[i].fillStable
            fillData.fillEnd =  self.fillDataList[i].fillEnd
            fillData.durationStable =  self.fillDataList[i].durationStable
            fillData.run =  self.fillDataList[i].run
            fillData.lsNo =  self.fillDataList[i].lsNo
            fillData.bunchSpacing =  self.fillDataList[i].bunchSpacing
            fillData.bField =  self.fillDataList[i].bField
            fillData.beamEnergy =  self.fillDataList[i].beamEnergy
	    fillData.tstamp = int(href.GetXaxis().GetBinCenter(i))
	    fillData.msecs = int(href.GetXaxis().GetBinCenter(i) - fillData.tstamp)
	    
	    lumiData.bestLumi = self.pbest.GetBinContent(i)
	    lumiData.bestLumiErr = self.pbest.GetBinError(i)
	    lumiData.hfLumi = self.phf.GetBinContent(i)
	    lumiData.hfLumiErr = self.phf.GetBinError(i)
	    lumiData.pltLumi = self.pplt.GetBinContent(i)
	    lumiData.pltLumiErr = self.pplt.GetBinError(i)
	    lumiData.pltZeroLumi = self.ppltZero.GetBinContent(i)
	    lumiData.pltZeroLumiErr = self.ppltZero.GetBinError(i)
	    lumiData.bcmfLumi = self.pbcmf.GetBinContent(i)
	    lumiData.bcmfLumiErr = 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
Example #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')

        fillData = FillData()
        lumiData = LumiData()
        radmonData = RadmonData()

        t.Branch(
            'fillBranch', fillData,
            'fill/I:fillStart/I:fillStable/I:fillEnd/I:durationStable/I:run/I:lsNo/I:tstamp/I:msecs/I:bunchSpacing/I'
        )
        t.Branch('fillBranchD', AddressOf(fillData, 'bField'),
                 'bField/D:beamEnergy/D')
        t.Branch(
            'lumiBranch', lumiData,
            'bestLumi/D:bestLumiErr/D:hfLumi/D:hfLumiErr/D:pltLumi/D:pltLumiErr/D:pltZeroLumi/D:pltZeroLumiErr/D:bcmfLumi/D:bcmfLumiErr/D'
        )
        t.Branch('radmonBranch', radmonData, 'rates[16]/D:ratesErr[16]/D')

        href = self.pbest  # Reference histogram
        #self.pbcmf.Draw()
        #raw_input("Press enter to continue")

        print "Starting filling tree, file ", radmonLumiFilePattern.replace(
            '__XXX__', str(self.fill))
        for i in range(len(self.xx) - 1):
            fillData.fill = self.fillDataList[i].fill
            fillData.fillStart = self.fillDataList[i].fillStart
            fillData.fillStable = self.fillDataList[i].fillStable
            fillData.fillEnd = self.fillDataList[i].fillEnd
            fillData.durationStable = self.fillDataList[i].durationStable
            fillData.run = self.fillDataList[i].run
            fillData.lsNo = self.fillDataList[i].lsNo
            fillData.bunchSpacing = self.fillDataList[i].bunchSpacing
            fillData.bField = self.fillDataList[i].bField
            fillData.beamEnergy = self.fillDataList[i].beamEnergy
            fillData.tstamp = int(href.GetXaxis().GetBinCenter(i))
            fillData.msecs = int(href.GetXaxis().GetBinCenter(i) -
                                 fillData.tstamp)

            lumiData.bestLumi = self.pbest.GetBinContent(i)
            lumiData.bestLumiErr = self.pbest.GetBinError(i)
            lumiData.hfLumi = self.phf.GetBinContent(i)
            lumiData.hfLumiErr = self.phf.GetBinError(i)
            lumiData.pltLumi = self.pplt.GetBinContent(i)
            lumiData.pltLumiErr = self.pplt.GetBinError(i)
            lumiData.pltZeroLumi = self.ppltZero.GetBinContent(i)
            lumiData.pltZeroLumiErr = self.ppltZero.GetBinError(i)
            lumiData.bcmfLumi = self.pbcmf.GetBinContent(i)
            lumiData.bcmfLumiErr = 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
Example #3
0
    def setupRanges(self):
	"""
	read file with lumi data 
	setup low edges of histograms corresponding to the beginning of lumisections
	fill array of fill  data (fill, ls, run) corresponding to the given bin
	"""
	
	lsection = -1
	
	fillData = FillData()
	fillReport = FillReport(fillReportName)
	
	#Start/End/Stable
	tsStart =  fillReport.getFillCreationTime(self.fill)
	tsEnd = fillReport.getFillEndTime(self.fill)
	tsStable = fillReport.getFillStableTime(self.fill)
	duration = fillReport.getFillDuration(self.fill)
	bField = fillReport.getFillField(self.fill)
	beamEnergy = fillReport.getFillBeamEnergy(self.fill)
	
	#Time range to look for radmon files
	self.fromto[0] = tsStart
	self.fromto[1] = tsEnd
	
	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.bestLumi > self.yMax:
		 self.yMax = tree.bestLumi
	    if tree.bestLumi < self.yMin:
		 self.yMin = tree.bestLumi
            
	    #Low edges for histos (start of LS)
	    if tree.lsNo != lsection:
		self.xx.append(tree.lsStart + tree.lsStartMs/1000000.)
		lsection = tree.lsNo
		
		# New lumisection - Add fill data
		fillData.fill = tree.fill
		fillData.fillStart = tsStart
		fillData.fillStable = tsStable
		fillData.fillEnd = tsEnd
		fillData.durationStable = duration
		fillData.bField = bField
		fillData.beamEnergy = beamEnergy
		fillData.bunchSpacing = tree.bunchSpacing
		fillData.run = tree.run
		fillData.lsNo = tree.lsNo

		self.fillDataList.append(fillData)
	
	print "Done setting up ranges for fill", self.fill, "\tNo of bins", len(self.xx) -1
	del tree
	del f
	del fillReport
	
	return  len(self.xx) -1
Example #4
0
    def setupRanges(self):
        """
	read file with lumi data 
	setup low edges of histograms corresponding to the beginning of lumisections
	fill array of fill  data (fill, ls, run) corresponding to the given bin
	"""

        lsection = -1

        fillData = FillData()
        fillReport = FillReport(fillReportName)

        #Start/End/Stable
        tsStart = fillReport.getFillCreationTime(self.fill)
        tsEnd = fillReport.getFillEndTime(self.fill)
        tsStable = fillReport.getFillStableTime(self.fill)
        duration = fillReport.getFillDuration(self.fill)
        bField = fillReport.getFillField(self.fill)
        beamEnergy = fillReport.getFillBeamEnergy(self.fill)

        #Time range to look for radmon files
        self.fromto[0] = tsStart
        self.fromto[1] = tsEnd

        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.bestLumi > self.yMax:
                self.yMax = tree.bestLumi
            if tree.bestLumi < self.yMin:
                self.yMin = tree.bestLumi

            #Low edges for histos (start of LS)
            if tree.lsNo != lsection:
                self.xx.append(tree.lsStart + tree.lsStartMs / 1000000.)
                lsection = tree.lsNo

                # New lumisection - Add fill data
                fillData.fill = tree.fill
                fillData.fillStart = tsStart
                fillData.fillStable = tsStable
                fillData.fillEnd = tsEnd
                fillData.durationStable = duration
                fillData.bField = bField
                fillData.beamEnergy = beamEnergy
                fillData.bunchSpacing = tree.bunchSpacing
                fillData.run = tree.run
                fillData.lsNo = tree.lsNo

                self.fillDataList.append(fillData)

        print "Done setting up ranges for fill", self.fill, "\tNo of bins", len(
            self.xx) - 1
        del tree
        del f
        del fillReport

        return len(self.xx) - 1