Example #1
0
File: isr.py Project: hardenbr/djpy
	def listOfSteps(self,config) :
		return ([
		supy.steps.printer.progressPrinter()]
		### pile-up reweighting
		+[supy.calculables.other.Target("pileupTrueNumInteractionsBX0",thisSample=config['baseSample'],
                                    target=(supy.whereami()+"/../data/pileup/HT300_Double_R12BCD_true.root","pileup"),
                                    groups=[('H',[])]).onlySim()] 
		+[supy.calculables.other.Target("HPt",thisSample=config['baseSample'],
                                    target=(supy.whereami()+"/../data/H400.root","hpt"),
                                    ).onlySim()] 
		### filters
		+[steps.other.genParticleMultiplicity(pdgIds=[6001114,6002114,6003114],collection='XpdgId',min=2,max=2)]

		### acceptance filters
		#+[supy.steps.filters.value('mygenHT',min=180)]
		+self.dijetSteps0()

		+[steps.efficiency.NX(pdfweights=None)]
		+[steps.efficiency.NXAcc(indicesAcc=self.AccCuts[-1]['name']+'Indices',pdfweights=None)]	

	
		+[supy.steps.filters.label('data cleanup'),
		supy.steps.filters.value('primaryVertexFilterFlag',min=1),
		supy.steps.filters.value('physicsDeclaredFilterFlag',min=1).onlyData(),
		supy.steps.filters.value('beamScrapingFilterFlag',min=1),
		supy.steps.filters.value('beamHaloTightFilterFlag',min=1),
		supy.steps.filters.value('hbheNoiseFilterFlag',min=1),
		supy.steps.filters.value('hcalLaserEventFilterFlag',min=1),
		supy.steps.filters.value('ecalLaserCorrFilterFlag',min=1),
		supy.steps.filters.value('eeBadScFilterFlag',min=1),
		supy.steps.filters.value('ecalDeadCellTPFilterFlag',min=1),
		supy.steps.filters.value('trackingFailureFilterFlag',min=1),
		]
		
		#+[steps.other.genParticleMultiplicity(6003114,min=2)]
		### trigger
		+[supy.steps.filters.label("hlt trigger"),
		steps.trigger.hltFilterWildcard("HLT_HT300_DoubleDisplacedPFJet60_v"),
		#steps.trigger.hltFilterWildcard("HLT_HT300_v"),
		supy.steps.filters.value('caloHT',min=325),
		]

		+self.dijetSteps1()
		+[steps.event.general()]
		+[
          steps.efficiency.NXReco(pdfweights=None,
              indicesRecoLow=self.IniCuts[-1]['name']+'Indices',
              indicesRecoHigh=self.IniCuts[-1]['name']+'Indices')
         ]	
		)
Example #2
0
File: other.py Project: elaird/supy
    def reportCache(self) :
        optstat = r.gStyle.GetOptStat()
        r.gStyle.SetOptStat(0)
        r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C"%whereami())
        r.setTDRStyle()
        r.tdrStyle.SetPadRightMargin(0.2)
        r.gStyle.SetPalette(1)
        self.setup()
        fileName = '/'.join(self.outputFileName.split('/')[:-1]+[self.name])
        sigmas = r.TH2D("sigmas","Contours of Integer Sigma, Gaussian Approximation;%s;%s"%self.labelsXY, *(self.binningX+self.binningY))
        for iX in range(1,1+sigmas.GetNbinsX()) :
            for iY in range(1,1+sigmas.GetNbinsY()) :
                xy = (sigmas.GetXaxis().GetBinCenter(iX),
                      sigmas.GetYaxis().GetBinCenter(iY),
                      1)
                sigmas.SetBinContent(iX, iY, math.sqrt( np.dot(xy, np.dot(self.matrix, xy) ) ) )

        sigmas.SetContour(6, np.array([0.1]+range(1,6),'d'))
        c = r.TCanvas()
        c.Print(fileName+'.pdf[')
        sigmas.Draw("cont3")
        c.Print(fileName+'.pdf')
        if self.xy :
            self.xy.UseCurrentStyle()
            self.xy.Draw('colzsame')
            sigmas.Draw('cont3same')
            c.Print(fileName+'.pdf')
        if hasattr(self,'xySup') :
            self.xySup.UseCurrentStyle()
            self.xySup.Draw('colz')
            sigmas.Draw('cont3same')
            c.Print(fileName+'.pdf')
        c.Print(fileName+'.pdf]')
        print 'Wrote : %s.pdf'%fileName
        r.gStyle.SetOptStat(optstat)
Example #3
0
File: other.py Project: elaird/supy
 def reportCache(self) :
     r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C"%whereami())
     r.setTDRStyle()
     r.gStyle.SetPalette(1)
     hists = self.setup()
     if not hists :
         print '%s.setup() failed'%self.name
         return
     fileName = '/'.join(self.outputFileName.split('/')[:-1]+[self.name]) + '.pdf'
     c = r.TCanvas()
     c.Print(fileName +'[')
     for h in hists.values() + [self.LR]:
         h.UseCurrentStyle()
         h.SetTitle(';'+self.label)
         h.SetLineWidth(2)
     hists['correct'].SetLineColor(r.kRed)
     hists['correct'].Draw('hist')
     hists['incorrect'].Draw('hist same')
     c.Print(fileName)
     self.LR.SetTitle(";%s;Likelihood Ratio, Correct:Incorrect"%self.label)
     self.LR.SetMinimum(0)
     self.LR.Draw('hist')
     c.Print(fileName)
     c.Print(fileName +']')
     print 'Wrote : %s'%fileName
Example #4
0
def plotExpLimit(analysis,n,org):

	denom = []
	for step in org.steps: 
		for plotName in sorted(step.keys()):
			if plotName == 'NE': denom=step[plotName]

	data={'bkg':[],'obs':[]}
	for step in org.steps:
		for plotName in sorted(step.keys()):
			if 'ABCDEFGHcounts' not in plotName : continue
			cutsidx=eval(plotName[:plotName.find('ABCDEFGH')])
			for j,sample in enumerate(org.samples):
				counts = getCounts(step[plotName][j])
				name=sample['name'].split('.')[0]
				if 'Data' in name: # get background estimate
					print cutsidx
					data['bkg'].append(getBkg(counts[:n],(analysis.scan[cutsidx],cutsidx)))
					data['obs'].append(counts[0])
				elif 'H' in name:
					if name not in data.keys(): 
						data[name] = []
						nEvents = float(sample['nEvents'])*0.09
					data[name].append((counts[0][0]/(denom[j].Integral()/4.),counts[0][1]/(denom[j].Integral()/4.)))

	import pickle
	pickle.dump(data,open(supy.whereami()+'/../results/data/data.pkl','w'))
Example #5
0
 def setupTdrStyle() :
     r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C"%whereami())
     r.setTDRStyle()
     #tweaks
     r.tdrStyle.SetPadRightMargin(0.06)
     r.tdrStyle.SetErrorX(r.TStyle().GetErrorX())
     r.gStyle.SetPalette(1)
Example #6
0
	def listOfSteps(self,config) :
		return ([
			supy.steps.printer.progressPrinter(),]

			### pile-up reweighting
			+[supy.calculables.other.Target("pileupTrueNumInteractionsBX0",thisSample=config['baseSample'],
				target=(supy.whereami()+"/../data/pileup/HT300_R12BCD_true.root","pileup"),
				groups=[('qcd',[]),('H',[])]).onlySim()] 

			### filters
			+[supy.steps.filters.label('data cleanup'),
			supy.steps.filters.value('primaryVertexFilterFlag',min=1),
            #supy.steps.filters.value('physicsDeclaredFilterFlag',min=1).onlyData(),
            supy.steps.filters.value('beamScrapingFilterFlag',min=1),
            supy.steps.filters.value('beamHaloTightFilterFlag',min=1),
            supy.steps.filters.value('hbheNoiseFilterFlag',min=1),
            supy.steps.filters.value('hcalLaserEventFilterFlag',min=1),
            supy.steps.filters.value('ecalLaserCorrFilterFlag',min=1),
            supy.steps.filters.value('eeBadScFilterFlag',min=1),
            supy.steps.filters.value('ecalDeadCellTPFilterFlag',min=1),
            supy.steps.filters.value('trackingFailureFilterFlag',min=1),
			]

			### trigger
			+[supy.steps.filters.label("hlt trigger"),
			steps.trigger.hltFilterWildcard("HLT_HT300_v"),
			supy.steps.filters.value("caloHT",min=325),]

			### plots
			+[steps.event.general()]
			+self.dijetSteps1()
			+self.discs()
			+self.dijetSteps2()
			)
Example #7
0
    def reportCache(self) :
        optStat = r.gStyle.GetOptStat()
        r.gStyle.SetOptStat(0)
        r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C"%whereami())
        r.setTDRStyle()
        r.tdrStyle.SetPadRightMargin(0.06)
        self.setup(None)
        if not self.hists :
            print '%s.setup() failed'%self.name
            r.gStyle.SetOptStat(optStat)
            return
        fileName = '/'.join(self.outputFileName.split('/')[:-1]+[self.name]) + '.pdf'
        c = r.TCanvas()
        c.Print(fileName +'[')

        stamp = r.TText()
        ssize = stamp.GetTextSize()

        for f in 'BQN' :
            leg = r.TLegend(0.31,0.65,0.9,0.95)
            #leg.SetHeader("#eta range")
            leg.SetFillColor(r.kWhite)
            leg.SetBorderSize(0)
            leg.SetTextFont(42)
            for i,(color,style) in enumerate(zip([r.kBlack,r.kRed,r.kBlue],[1,7,8])) :
                h = self.hists[f+str(i)]
                label = h.GetTitle().split(',')[1].replace("0.000<","").replace("<"," < ")
                letter = h.GetTitle().split(',')[0]
                h.SetTitle(';#lower[0.2]{p_{#lower[-0.25]{T}}^{meas} (GeV)};#lower[-0.15]{Median log(E^{#lower[0.4]{gen}}/E^{#lower[0.4]{meas}})}')
                h.SetLineColor(color)
                h.SetLineStyle(style)
                h.SetLineWidth(3 if style!=1 else 2)
                h.SetMaximum(0.2)
                h.SetMinimum(-0.2)
                h.Draw("histsame" if i else "hist")
                stamp.SetTextFont(42)
                stamp.SetTextSize(ssize)
                stamp.DrawTextNDC(0.2,0.2, {'B':'Jets from b quark hadronization', 'Q':'Jets from W boson decay', 'N':'Other jets'}[letter])
                leg.AddEntry(h,label,'l')
            leg.Draw()
            r.gPad.RedrawAxis()

            stamp.SetTextFont(62)
            stamp.SetTextSize(ssize)
            stamp.DrawTextNDC(0.16 ,0.96,"CMS")
            stamp.SetTextFont(52)
            stamp.SetTextSize(0.8 * ssize)
            stamp.DrawTextNDC(0.27, 0.96, "Simulation")
            stamp.SetTextFont(42)
            stamp.SetTextSize(ssize)
            stamp.DrawTextNDC(0.8, 0.96, "(8 TeV)")

            c.Print(fileName)
        c.Print(fileName +']')
        print 'Wrote : %s'%fileName
        r.gStyle.SetOptStat(optStat)
Example #8
0
    def reportCache(self) :
        optStat = r.gStyle.GetOptStat()
        r.gStyle.SetOptStat(0)
        r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C"%whereami())
        r.setTDRStyle()
        self.setup(None)
        for hist in filter(None,self.histsBQN) :
            hist.Scale(1./hist.Integral(0,hist.GetNbinsX()+1))
        if None in self.histsBQN :
            print '%s.setup() failed'%self.name
            r.gStyle.SetOptStat(optStat)
            return
        fileName = '/'.join(self.outputFileName.split('/')[:-1]+[self.name]) + '.pdf'
        c = r.TCanvas()
        c.Print(fileName +'[')
        leg = r.TLegend(0.18,0.45,0.95,0.75)
        #leg.SetHeader("jet flavor")
        leg.SetFillColor(r.kWhite)
        leg.SetBorderSize(0)
        leg.SetTextFont(42)
        for h in self.histsBQN :
            h.Fill(h.GetBinCenter(1), h.GetBinContent(0))
            h.SetBinContent(0,0)
        height = 1.1 * max(h.GetMaximum() for h in self.histsBQN)
        for i,(f,color,style) in enumerate(zip('BQN',[r.kBlack,r.kRed,r.kBlue],[1,7,8])) :
            h = self.histsBQN[i]
            h.UseCurrentStyle()
            h.SetTitle(";%s;Probability / %.2f"%(h.GetXaxis().GetTitle().split()[0].replace('jet',''),(self.binning[2]-self.binning[1]) / self.binning[0]))
            h.SetLineColor(color)
            h.SetLineWidth(2 if style==1 else 3)
            h.SetLineStyle(style)
            h.SetMaximum(height)
            h.SetMinimum(0)
            h.Draw("hist" + ("same" if i else ""))
            leg.AddEntry(h,{"B":"Jets from b quark hadronization","Q":"Jets from W boson decay","N":"Other jets"}[f],'l')
        leg.Draw()
        r.gPad.RedrawAxis()

        stamp = r.TText()
        ssize = stamp.GetTextSize()
        stamp.SetTextFont(62)
        stamp.SetTextSize(ssize)
        stamp.DrawTextNDC(0.20 ,0.88,"CMS")
        stamp.SetTextFont(52)
        stamp.SetTextSize(0.8 * ssize)
        stamp.DrawTextNDC(0.20, 0.83, "Simulation")
        stamp.SetTextFont(42)
        stamp.SetTextSize(ssize)
        stamp.DrawTextNDC(0.84, 0.96, "(8 TeV)")


        c.Print(fileName)
        c.Print(fileName +']')
        print 'Wrote : %s'%fileName
        r.gStyle.SetOptStat(optStat)
Example #9
0
File: isr.py Project: hardenbr/djpy
	def totalEfficiencies(self,org,dir=None,flavor='') :
		recoLow,recoHigh,acceptance,denom=None,None,None,None
		for step in org.steps:
			for plotName in sorted(step.keys()):
				if 'NXLow'+flavor == plotName : recoLow=step[plotName]
				if 'NXHigh'+flavor == plotName : recoHigh=step[plotName]
				if 'NXAcc'+flavor == plotName : acceptance=step[plotName]
				if 'NX'+flavor == plotName : denom=step[plotName]

		acc = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(acceptance,denom)])
		efflow = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoLow,denom)])
		effhigh = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoHigh,denom)])
		effacclow = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoLow,acceptance)])
		effacchigh = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoHigh,acceptance)])
	
		fs = [0.4,0.6,1.,1.4]	
		allfs = [0.1*a for a in fs] 
		allfs += fs 
		allfs += [10*a for a in fs]
		allfs = [round(a,5) for a in allfs] 
		N=len(allfs)

		f=1.
		sysmap={'1000350':0.08,'1000150':0.08,'400150':0.1,'40050':0.08,'20050':0.22}

		import pickle,math
		for i,sample in enumerate(org.samples):
			name = sample['name'].split('.')[0]
			H,X=name.split('_')[1],name.split('_')[3]
			sys=sysmap[H+X]
			ctau = self.ctau[self.sig_names.index(name)]
			for j in range(N):
				x,y=r.Double(0),r.Double(0)
				eff = effhigh
				effacc = effacchigh
				if j<N/3: 
					eff = efflow
					effacc = effacclow
				eff[i].GetPoint(j,x,y)
				e = f*float(y)
				eErr = f*eff[i].GetErrorY(j)
				effacc[i].GetPoint(j,x,y)
				ea = f*float(y)
				eaErr = f*effacc[i].GetErrorY(j)
				acc[i].GetPoint(j,x,y)
				a = float(y)
				aErr = acc[i].GetErrorY(j)
				#if e > 0. : eErr = e*math.sqrt(sys*sys+pow(eErr/e,2))
				#else : eErr = 0.
				#if ea > 0. : eaErr = ea*math.sqrt(sys*sys+pow(eaErr/ea,2))
				#else : eaErr = 0.
				factor=allfs[j]
				print H,X,factor,a,aErr,e,eErr,ea,eaErr
				data=[(a,aErr),(e,eErr),[ea,eaErr]]
				pickle.dump(data,open(supy.whereami()+'/../results/'+dir+'/efficiencies/'+name+'_'+str(factor)+'.pkl','w'))
Example #10
0
	def totalEfficiencies(self,org,dir=None,flavor='') :
		recoLow,recoHigh,acceptance,denom=None,None,None,None
		for step in org.steps:
			for plotName in sorted(step.keys()):
				if 'LowNX'+flavor == plotName : recoLow=step[plotName]
				if 'HighNX'+flavor == plotName : recoHigh=step[plotName]
				if 'AccNX'+flavor == plotName : acceptance=step[plotName]
				if 'NX'+flavor == plotName : denom=step[plotName]

		acc = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(acceptance,denom)])
		efflow = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoLow,denom)])
		effhigh = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoHigh,denom)])
		effacclow = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoLow,acceptance)])
		effacchigh = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoHigh,acceptance)])
	
		fs = [0.01,0.02,0.03,0.06,0.1,0.2,0.3,0.6,1.,2.,3.,6.,10.,20.,30.,60.,100.]
		fs = [round(a,5) for a in fs] 
		N=len(fs)

		f=0.89
		sysmap={'1500494':0.10,'1000148':0.10,'350148':0.10,'12048':0.10}


		import pickle,math,re
		for i,sample in enumerate(org.samples):
			digits = re.findall(r'\d+',sample['name'])
			SQ,CHI=digits[0],digits[2]
			name='SQ_'+str(SQ)+"_CHI_"+str(CHI)
			sys=0.10
			ctau = self.ctau[self.sig_names.index(name)]
			for j in range(N):
				x,y=r.Double(0),r.Double(0)
				eff = efflow
				effacc = effacclow
				eff[i].GetPoint(j,x,y)
				e = f*float(y)
				eErr = f*eff[i].GetErrorY(j)
				effacc[i].GetPoint(j,x,y)
				ea = f*float(y)
				eaErr = f*effacc[i].GetErrorY(j)
				acc[i].GetPoint(j,x,y)
				a = float(y)
				aErr = acc[i].GetErrorY(j)
				if e > 0. : eErr = e*math.sqrt(sys*sys+pow(eErr/e,2))
				else : eErr = 0.
				if ea > 0. : eaErr = ea*math.sqrt(sys*sys+pow(eaErr/ea,2))
				else : eaErr = 0.
				factor=fs[j]
				print SQ,CHI,factor,a,aErr,e,eErr,ea,eaErr
				data=[(a,aErr),(e,eErr),[ea,eaErr]]
				pickle.dump(data,open(supy.whereami()+'/../results/'+dir+'/efficiencies/'+name+'_'+str(factor)+'.pkl','w'))
Example #11
0
 def reportCache(self):
     if not self.activated:
         print '%s: Not activated' % self.name
         return
     optStat = r.gStyle.GetOptStat()
     r.gStyle.SetOptStat(0)
     r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C" % whereami())
     r.setTDRStyle()
     self.setup(None)
     if None in self.histsBN:
         print '%s.setup() failed' % self.name
         r.gStyle.SetOptStat(optStat)
         return
     fileName = '/'.join(self.outputFileName.split('/')[:-1] +
                         [self.name]) + '.pdf'
     c = r.TCanvas()
     c.Print(fileName + '[')
     histlist = [
         self.histsBN, self.cdfBN, self.cdfBN_d, self.sfBN, self.funcsBN
     ]
     titles = [
         ";CSV';pdf", ";CSV';cdf", ";CSV;cdf",
         ";CSV Working Point;Scale Factor", ";CSV';CSV\""
     ]
     for hists, title in zip(histlist, titles):
         leg = r.TLegend(0.36, 0.55, 0.6, 0.7)
         leg.SetHeader("jet flavor")
         height = 1.1 * max(h.GetMaximum() for h in hists)
         if height < 0: height = 1.1 * max(sum(self.sfPointsBN, []))
         for i, (f,
                 color) in enumerate(zip('BN',
                                         [r.kRed, r.kBlue, r.kGreen])):
             h = hists[i]
             h.SetTitle(title)
             h.UseCurrentStyle()
             h.SetLineColor(color)
             h.SetLineWidth(2)
             h.SetMarkerColor(color)
             h.SetMaximum(height)
             h.SetMinimum(0)
             h.Draw("hist" + ("same" if i else "")) if type(
                 h) != r.TGraph else h.Draw("APL"[1 if i else None:])
             leg.AddEntry(h, {"B": "B jets", "N": "other jets"}[f], 'l')
         leg.Draw()
         c.Print(fileName)
     c.Print(fileName + ']')
     print 'Wrote : %s' % fileName
     r.gStyle.SetOptStat(optStat)
Example #12
0
	def totEvtEff(self,org,dir=None):
		high1,low1,denom=None,None,None
		for step in org.steps:
			for plotName in sorted(step.keys()):
				if 'HighNE1' == plotName : high1=step[plotName]
				if 'LowNE1' == plotName : low1=step[plotName]
				if 'NE' == plotName : denom=step[plotName]

		efflow1 = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(low1,denom)])
		effhigh1 = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(high1,denom)])

		fs = [0.4,0.6,1.,1.4]#	old factors for the record if not approved
		#fs = [0.1,0.2,0.3,0.6,1.,2.,3.,6.,10.]
		allfs = [0.1*a for a in fs] + fs + [10*a for a in fs]
		allfs = [round(a,5) for a in allfs] 
		N=len(allfs)
		forbidden=[7,8,9,16,17,18]

		sysmap={'1000350':0.075,'1000150':0.075,'400150':0.096,'40050':0.091,'20050':0.10}
		f=0.89

		for i,sample in enumerate(org.samples):
			digits=re.findall(r'\d+',sample['name'])
			H,X=digits[1],digits[4]
			sys=sysmap[H+X]
			name='H_'+str(H)+'_X_'+str(X)
			ctau = self.ctau[self.sig_names.index(name)]

			for j in range(N):
				#if j in forbidden: continue
				x,y=r.Double(0),r.Double(0)
				efflow1[i].GetPoint(j,x,y)
				e1 = f*float(y)
				e1Err = f*efflow1[i].GetErrorY(j)
				if j>N/3:
					effhigh1[i].GetPoint(j,x,y)
					e1p = f*float(y)
					e1pErr = f*effhigh1[i].GetErrorY(j)

				if e1 > 0. : e1Err = e1*math.sqrt(sys*sys+pow(e1Err/e1,2))
				factor=allfs[j]
				#if factor in [0.1,1,10]:
				objects=[ H,X,factor*ctau,rnd(100*e1,3)]
				print " & ".join(str(a) for a in objects ) + ' \\\\'
				output=[(e1,e1Err),(e1,e1Err),[e1,e1Err]]
				pickle.dump(output,open(supy.whereami()+'/../results/'+dir+'/efficiencies/'+name+'_'+str(factor)+'.pkl','w'))
Example #13
0
	def listOfSteps(self,config) :
		return ([
			supy.steps.printer.progressPrinter(),]

			### pile-up reweighting
			+[supy.calculables.other.Target("pileupTrueNumInteractionsBX0",thisSample=config['baseSample'],
				target=(supy.whereami()+"/../data/pileup/HT300_Double_R12BCD_true.root","pileup"),
				groups=[('qcd',[]),('H',[])]).onlySim()] 

			### signal filters
			+[steps.other.genParticleMultiplicity(pdgIds=[6002114],collection='XpdgId',min=2,max=2).onlySim()]
			+[steps.efficiency.NE(pdfweights=None).onlySim()]	

			### filters
			+[supy.steps.filters.label('data cleanup'),
			supy.steps.filters.value('primaryVertexFilterFlag',min=1),
            supy.steps.filters.value('physicsDeclaredFilterFlag',min=1).onlyData(),
            supy.steps.filters.value('beamScrapingFilterFlag',min=1),
            supy.steps.filters.value('beamHaloTightFilterFlag',min=1),
            supy.steps.filters.value('hbheNoiseFilterFlag',min=1),
            supy.steps.filters.value('hcalLaserEventFilterFlag',min=1),
            supy.steps.filters.value('ecalLaserCorrFilterFlag',min=1),
            supy.steps.filters.value('eeBadScFilterFlag',min=1),
            supy.steps.filters.value('ecalDeadCellTPFilterFlag',min=1),
            supy.steps.filters.value('trackingFailureFilterFlag',min=1),
			]

			### trigger
			+[supy.steps.filters.label("hlt trigger"),
            steps.trigger.hltFilterWildcard("HLT_HT300_DoubleDisplacedPFJet60_v"),
			supy.steps.filters.value("caloHT",min=325),
			#steps.event.runModulo(modulo=11,inverted=True).onlyData(),
			]

			### plots
			+[steps.event.general()]
			+self.dijetSteps1()
			+[supy.steps.histos.multiplicity(self.Cuts[-2]['name']+'Indices')]
			+[supy.steps.histos.multiplicity(self.Cuts[-1]['name']+'Indices')]
			+self.discs()
			+self.dijetSteps2()
			)
Example #14
0
	def totalEfficiencies(self,org,dir=None,flavor='') :
		recoLow,recoHigh,acceptance,denom=None,None,None,None
		for step in org.steps:
			for plotName in sorted(step.keys()):
				if 'LowNE1+'+flavor == plotName : recoLow=step[plotName]
				if 'HighNE1+'+flavor == plotName : recoHigh=step[plotName]
				if 'NE'+flavor == plotName : denom=step[plotName]
		print recoLow
		print denom

		efflow = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoLow,denom)])
		effhigh = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(recoHigh,denom)])
	
		fs = [0.4,0.6,1.,1.4]	
		allfs = [0.1*a for a in fs] 
		allfs += fs 
		allfs += [10*a for a in fs]
		allfs = [round(a,5) for a in allfs] 
		N=len(allfs)

		f=1.

		import pickle,math
		for i,sample in enumerate(org.samples):
			name = sample['name'].split('.')[0]
			H,X=name.split('_')[1],name.split('_')[3]
			ctau = self.ctau[self.sig_names.index(name)]
			for j in range(N):
				x,y=r.Double(0),r.Double(0)
				eff = effhigh
				if j<N/3: 
					eff = efflow
				eff[i].GetPoint(j,x,y)
				e = f*float(y)
				eErr = f*eff[i].GetErrorY(j)
				factor=allfs[j]
				print H,X,factor,e,eErr
				data=[(e,eErr),(e,eErr),[e,eErr]]
				pickle.dump(data,open(supy.whereami()+'/../results/'+dir+'/efficiencies/'+name+'_'+str(factor)+'.pkl','w'))
Example #15
0
 def reportCache(self) :
     if not self.activated:
         print '%s: Not activated' % self.name
         return
     optStat = r.gStyle.GetOptStat()
     r.gStyle.SetOptStat(0)
     r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C"%whereami())
     r.setTDRStyle()
     self.setup(None)
     if None in self.histsBN :
         print '%s.setup() failed'%self.name
         r.gStyle.SetOptStat(optStat)
         return
     fileName = '/'.join(self.outputFileName.split('/')[:-1]+[self.name]) + '.pdf'
     c = r.TCanvas()
     c.Print(fileName +'[')
     histlist = [self.histsBN, self.cdfBN, self.cdfBN_d, self.sfBN, self.funcsBN]
     titles = [";CSV';pdf",";CSV';cdf",";CSV;cdf",";CSV Working Point;Scale Factor",";CSV';CSV\""]
     for hists,title in zip(histlist, titles):
         leg = r.TLegend(0.36,0.55,0.6,0.7)
         leg.SetHeader("jet flavor")
         height = 1.1 * max(h.GetMaximum() for h in hists)
         if height<0: height = 1.1 * max(sum(self.sfPointsBN,[]))
         for i,(f,color) in enumerate(zip('BN',[r.kRed,r.kBlue,r.kGreen])) :
             h = hists[i]
             h.SetTitle(title)
             h.UseCurrentStyle()
             h.SetLineColor(color)
             h.SetLineWidth(2)
             h.SetMarkerColor(color)
             h.SetMaximum(height)
             h.SetMinimum(0)
             h.Draw("hist" + ("same" if i else "")) if type(h)!=r.TGraph else h.Draw("APL"[1 if i else None:])
             leg.AddEntry(h,{"B":"B jets","N":"other jets"}[f],'l')
         leg.Draw()
         c.Print(fileName)
     c.Print(fileName +']')
     print 'Wrote : %s'%fileName
     r.gStyle.SetOptStat(optStat)
Example #16
0
	def totEvtEff(self,org,dir=None):
		low1p,low1,low2p,denom,lowNX,denomX=None,None,None,None,None,None
		for step in org.steps:
			for plotName in sorted(step.keys()):
				if 'LowNE1' == plotName : low1=step[plotName]
				if 'NE' == plotName : denom=step[plotName]
				if 'NX' == plotName: denomX=step[plotName]

		efflow1 = tuple([r.TGraphAsymmErrors(n,d,"cl=0.683 n") for n,d in zip(low1,denom)])

		#fs = [0.01,0.02,0.03,0.06,0.1,0.2,0.3,0.6,1.,2.,3.,6.,10.,20.,30.,60.,100.]
		fs = [0.4,0.6,1.,1.4]
		fs = [round(a,5) for a in fs] 
		N=len(fs)

		sysmap={'1500494':0.10,'1000148':0.10,'350148':0.10,'12048':0.10}
		f=0.89

		for i,sample in enumerate(org.samples):
			digits=re.findall(r'\d+',sample['name'])
			SQ,CHI=digits[0],digits[1]
			name='SQ_'+str(SQ)+"_CHI_"+str(CHI) + ('_priv' if 'priv' in sample['name'] else '')
			sys=0.1

			ctau = self.ctau[self.sig_names.index(name)]

			for j in range(N):
				x,y=r.Double(0),r.Double(0)
				efflow1[i].GetPoint(j,x,y)
				e1 = f*float(y)
				e1Err = f*efflow1[i].GetErrorY(j)
				if e1 > 0. : e1Err = e1*math.sqrt(sys*sys+pow(e1Err/e1,2))
				factor=fs[j]
				#if factor in [0.1,1,10]:
				objects=[ SQ,CHI,factor*ctau,rnd(100*e1,3),rnd(100*e1Err,3)]
				print " & ".join(str(a) for a in objects ) + ' \\\\'
				output=[(e1,e1Err),(e1,e1Err),[e1,e1Err]]
				name = name.replace('_priv','')
				pickle.dump(output,open(supy.whereami()+'/../results/'+dir+'/efficiencies/'+name+'_'+str(factor)+'.pkl','w'))
Example #17
0
	def listOfSteps(self,config) :
		return ([
			supy.steps.printer.progressPrinter()]

			### filters
			+[supy.steps.filters.label('data cleanup'),
			supy.steps.filters.value('primaryVertexFilterFlag',min=1),
			supy.steps.filters.value('physicsDeclaredFilterFlag',min=1).onlyData(),
			supy.steps.filters.value('beamScrapingFilterFlag',min=1),
			supy.steps.filters.value('beamHaloTightFilterFlag',min=1),
			supy.steps.filters.value('hbheNoiseFilterFlag',min=1),
			supy.steps.filters.value('hcalLaserEventFilterFlag',min=1),
			supy.steps.filters.value('ecalLaserCorrFilterFlag',min=1),
			supy.steps.filters.value('eeBadScFilterFlag',min=1),
			supy.steps.filters.value('ecalDeadCellTPFilterFlag',min=1),
			supy.steps.filters.value('trackingFailureFilterFlag',min=1),
            ]

			### pile-up reweighting
			+[supy.calculables.other.Target("pileupTrueNumInteractionsBX0",thisSample=config['baseSample'],
				target=(supy.whereami()+"/../data/pileup/HT250_R12BCD_true.root","pileup"),
				groups=[('qcd',[]),('H',[])]).onlySim()] 

			### trigger
			+[supy.steps.filters.label("hlt trigger"),
			steps.trigger.hltFilterWildcard("HLT_HT250_v"),
			#steps.trigger.hltFilterWildcard("HLT_HT300_DoubleDisplacedPFJet60_v",veto=True),
			steps.trigger.hltIsPresent("HLT_HT300_v"),]
			+self.dijetSteps()
			+[steps.event.general(),
			supy.steps.histos.generic('pfHT',60,250,550,suffix="lower",title='; pfHT [GeV] ; events / bin'),
			supy.steps.histos.generic('caloHT',60,250,550,suffix="lower",title='; caloHT [GeV] ; events / bin'),
			steps.trigger.hltFilterWildcard("HLT_HT300_v"),
			steps.event.general(),
			supy.steps.histos.generic('pfHT',60,250,550,suffix="higher",title='; pfHT [GeV] ; events / bin'),
			supy.steps.histos.generic('caloHT',60,250,550,suffix="higher",title='; caloHT [GeV] ; events / bin'),]
			)
Example #18
0
 def listOfSteps(self, config):
     return (
         [
             supy.steps.printer.progressPrinter(),
             ### filters
             supy.steps.filters.label("data cleanup"),
             supy.steps.filters.value("primaryVertexFilterFlag", min=1),
             supy.steps.filters.value("physicsDeclaredFilterFlag", min=1).onlyData(),
             supy.steps.filters.value("beamScrapingFilterFlag", min=1),
             supy.steps.filters.value("beamHaloTightFilterFlag", min=1),
             supy.steps.filters.value("hbheNoiseFilterFlag", min=1),
             supy.steps.filters.value("hcalLaserEventFilterFlag", min=1),
             supy.steps.filters.value("ecalLaserCorrFilterFlag", min=1),
             supy.steps.filters.value("eeBadScFilterFlag", min=1),
             supy.steps.filters.value("ecalDeadCellTPFilterFlag", min=1),
             supy.steps.filters.value("trackingFailureFilterFlag", min=1),
         ]
         ### pile-up reweighting
         + [
             supy.calculables.other.Target(
                 "pileupTrueNumInteractionsBX0",
                 thisSample=config["baseSample"],
                 target=(supy.whereami() + "/../data/pileup/HT300_R12BCD_true.root", "pileup"),
                 groups=[("qcd", []), ("H", [])],
             ).onlySim()
         ]
         ### trigger
         + [
             supy.steps.filters.label("hlt trigger"),
             steps.trigger.hltFilterWildcard("HLT_HT300_v"),
             # steps.trigger.hltFilterWildcard("HLT_HT300_DoubleDisplacedPFJet60_v",veto=True),
             steps.trigger.hltTriggerObjectMultiplicity("hlt2DisplacedHT300L1FastJetL3Filter", min=2),
         ]
         ### plots
         + [steps.event.general()]
         + self.jetPlots()
     )
Example #19
0
    def totalEfficiencies(self, org, dir=None, flavor=''):
        recoLow, recoHigh, acceptance, denom = None, None, None, None
        for step in org.steps:
            for plotName in sorted(step.keys()):
                if 'LowNX' + flavor == plotName: recoLow = step[plotName]
                if 'HighNX' + flavor == plotName: recoHigh = step[plotName]
                if 'AccNX' + flavor == plotName: acceptance = step[plotName]
                if 'NX' + flavor == plotName: denom = step[plotName]

        acc = tuple([
            r.TGraphAsymmErrors(n, d, "cl=0.683 n")
            for n, d in zip(acceptance, denom)
        ])
        efflow = tuple([
            r.TGraphAsymmErrors(n, d, "cl=0.683 n")
            for n, d in zip(recoLow, denom)
        ])
        effhigh = tuple([
            r.TGraphAsymmErrors(n, d, "cl=0.683 n")
            for n, d in zip(recoHigh, denom)
        ])
        effacclow = tuple([
            r.TGraphAsymmErrors(n, d, "cl=0.683 n")
            for n, d in zip(recoLow, acceptance)
        ])
        effacchigh = tuple([
            r.TGraphAsymmErrors(n, d, "cl=0.683 n")
            for n, d in zip(recoHigh, acceptance)
        ])

        #fs = [0.4,0.6,1.,1.4]	old factors for the record if not approved
        fs = [0.1, 0.2, 0.3, 0.6, 1., 2., 3., 6., 10.]
        allfs = [0.1 * a for a in fs]
        allfs += fs
        allfs += [10 * a for a in fs]
        allfs = [round(a, 5) for a in allfs]
        N = len(allfs)

        forbidden = [7, 8, 9, 16, 17, 18]

        f = 0.89
        sysmap = {
            '1000350': 0.075,
            '1000150': 0.075,
            '400150': 0.096,
            '40050': 0.091,
            '20050': 0.10
        }

        for i, sample in enumerate(org.samples):
            digits = re.findall(r'\d+', sample['name'])
            H, X = digits[0], digits[2]
            name = 'H_' + str(H) + '_X_' + str(X)
            sys = sysmap[H + X]
            ctau = self.ctau[self.sig_names.index(name)]

            data = {}
            for factor in set(allfs):
                data[factor] = []

            for j in range(N):
                if j in forbidden: continue
                x, y = r.Double(0), r.Double(0)
                eff = effhigh
                effacc = effacchigh
                if j < N / 3:
                    eff = efflow
                    effacc = effacclow
                eff[i].GetPoint(j, x, y)
                e = f * float(y)
                eErr = f * eff[i].GetErrorY(j)
                effacc[i].GetPoint(j, x, y)
                ea = f * float(y)
                eaErr = f * effacc[i].GetErrorY(j)
                acc[i].GetPoint(j, x, y)
                a = float(y)
                aErr = acc[i].GetErrorY(j)
                #if e > 0. : eErr = e*math.sqrt(sys*sys+pow(eErr/e,2))
                #else : eErr = 0.
                #if ea > 0. : eaErr = ea*math.sqrt(sys*sys+pow(eaErr/ea,2))
                #else : eaErr = 0.
                factor = allfs[j]
                #print H,X,factor,a,aErr,e,eErr,ea,eaErr
                output = [(a, aErr), (e, eErr), [ea, eaErr]]
                data[factor].append(output)

                #pickle.dump(output,open(supy.whereami()+'/../results/'+dir+'/efficiencies/'+name+'_'+str(factor)+'_'+str(j)+'.pkl','w'))

            for factor in data.keys():
                list = data[factor]
                ac = [obj[0][0] for obj in list if obj[0][0] > 0]
                acErr = [obj[0][1] for obj in list if obj[0][0] > 0]
                ef = [obj[1][0] for obj in list if obj[1][0] > 0]
                efErr = [obj[1][1] for obj in list if obj[1][0] > 0]
                efac = [obj[2][0] for obj in list if obj[2][0] > 0]
                efacErr = [obj[2][1] for obj in list if obj[2][0] > 0]
                if len(ef) == 0: continue
                e, eErr = weightedAvg(ef, efErr)
                a, aErr = weightedAvg(ac, acErr)
                ea, eaErr = weightedAvg(efac, efacErr)
                #eErr = e*math.sqrt(sys*sys+pow(eErr/e,2))
                #eaErr = ea*math.sqrt(sys*sys+pow(eaErr/ea,2))
                print H, X, factor, a, aErr, e, eErr, ea, eaErr
                output = [(a, aErr), (e, eErr), [ea, eaErr]]
                pickle.dump(
                    output,
                    open(
                        supy.whereami() + '/../results/' + dir +
                        '/efficiencies/' + name + '_' + str(factor) + '.pkl',
                        'w'))
Example #20
0
def cppFiles() :
    return [whereami()+"/../cpp/dict.cpp"]
Example #21
0
    def listOfSampleDictionaries(self) :
        localDict = supy.samples.SampleHolder()
        filePath = "%s/%s/integers.root"%(supy.whereami(),configuration.localpath())
	localDict.add('integers','["%s"]'%filePath, lumi=0.009)
        return [localDict]
Example #22
0
def fileName():
    return "%s/%s/skim.root" % (supy.whereami(), configuration.localpath())
Example #23
0
import os
from supy import sites, whereami


__prefix = "%s/sites/%s" % (whereami(), sites.prefix())


def subScript():
    return "%sSub.sh" % __prefix


def jobTemplate():
    return "%sJob.sh" % __prefix


def condorTemplate():
    return  "%sTemplate.condor" % __prefix


def baseDir(fileName=""):
    return fileName[:fileName.rfind('/')]


def condored(script):
    return script.replace(".sh", ".condor") if os.path.exists(condorTemplate()) else script


def jobScriptFull(base="", tag="", sample="", iSlice=None, **_):
    return "/".join([base, tag, sample, "job%d.sh" % iSlice])

Example #24
0
    def reportCache(self):
        fileName = '/'.join(self.outputFileName.split('/')[:-1] + [self.name])
        optstat = r.gStyle.GetOptStat()
        from supy import whereami
        r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C" % whereami())
        r.setTDRStyle()
        r.tdrStyle.SetOptStat(0)
        r.tdrStyle.SetOptFit(0)
        r.tdrStyle.SetPalette(1)
        r.tdrStyle.SetMarkerSize(0.5)
        r.tdrStyle.SetTitleH(0.05)
        r.tdrStyle.SetTitleW(0.4)
        r.tdrStyle.SetTitleX(0.4)
        r.tdrStyle.SetTitleY(1.0)
        r.tdrStyle.SetTitleBorderSize(0)

        samples = self.baseSamples()
        names = [
            '%s#rightarrow^{}t#bar{t} ' % i
            for i in ['gg', 'qg', 'q#bar{q}', '#bar{q}g']
        ]
        colors = [r.kBlack, r.kBlue, r.kRed, r.kGreen]

        hists = [
            self.fromCache(samples, ['2_x_y'], self.altTag)[s]['2_x_y']
            for s in samples
        ]
        for h in hists:
            h.UseCurrentStyle()
            h.SetTitle(';X_{T};X_{L}')
        symmHists, antiHists = zip(*[self.prep(h) for h in hists])
        symm, symm0, symm1, symm2 = zip(*symmHists)
        anti, anti0, anti1 = zip(*antiHists)

        for h, n in zip(symm, names):
            h.SetTitle(n + ' (symmetric)')
        for h, n in zip(anti, names):
            h.SetTitle(n + ' (antisymmetric)')

        height = max(h.GetBinContent(h.GetMaximumBin()) for h in symm)
        c = r.TCanvas()
        c.Print(fileName + '.pdf[')
        c.Divide(2, 2)
        r.tdrStyle.SetOptTitle(1)
        for i, h in enumerate(symm):
            c.cd(i + 1)
            h.SetMaximum(height)
            h.SetMinimum(0)
            h.Draw('colz')
        c.Print(fileName + '.pdf')
        #for i,h in enumerate(symm) :
        #    c.cd(i+1)
        #    h.Draw('surf2')
        #c.Print(fileName+'.pdf')
        r.tdrStyle.SetOptTitle(0)

        c.Clear()
        c.cd(0)

        for par in range(3):
            hists = eval('symm%d' % par)
            height = 1.05 * max(
                h.GetBinContent(h.GetMaximumBin()) for h in hists)
            for i, h in enumerate(hists):
                h.GetYaxis().SetTitle('Fitted value of ' +
                                      h.GetTitle().split('=')[-1])
                fit = next(iter(h.GetListOfFunctions()), None)
                if fit:
                    fit.SetLineColor(colors[i])
                    fit.SetLineWidth(1)
                h.SetLineColor(colors[i])
                h.SetMarkerColor(colors[i])
                h.SetMaximum(height)
                h.SetMinimum(-height if h.GetMinimum() < 0 else 0)
                h.Draw('same' if i else '')
            c.Print(fileName + '.pdf')

        c.Clear()
        c.Divide(2, 2)
        r.tdrStyle.SetOptTitle(1)
        height = max(h.GetBinContent(h.GetMaximumBin()) for h in anti)
        for i, h in enumerate(anti):
            c.cd(i + 1)
            h.SetMaximum(height)
            h.SetMinimum(-height)
            h.Draw('colz')
        c.Print(fileName + '.pdf')
        #for i,h in enumerate(anti) :
        #    c.cd(i+1)
        #    h.Draw('surf2')
        #c.Print(fileName+'.pdf')
        r.tdrStyle.SetOptTitle(0)

        c.Clear()
        c.cd(0)

        for par in range(2):
            hists = eval('anti%d' % par)
            height = 1.05 * max(
                [h.GetBinContent(h.GetMaximumBin())
                 for h in hists] + [abs(h.GetMinimum()) for h in hists])
            for i, h in enumerate(hists):
                h.GetYaxis().SetTitle('Fitted value of ' +
                                      h.GetTitle().split('=')[-1])
                fit = next(iter(h.GetListOfFunctions()), None)
                if fit:
                    fit.SetLineColor(colors[i])
                    fit.SetLineWidth(1)
                h.SetLineColor(colors[i])
                h.SetMarkerColor(colors[i])
                h.SetMaximum(height)
                h.SetMinimum(-height)
                h.Draw('same' if i else '')
            c.Print(fileName + '.pdf')

        c.Clear()

        height = 1.1 * max(h.GetMaximum() for h in symm)
        funcs = [next(iter(s.GetListOfFunctions()), None) for s in symm]
        [(func.SetLineStyle(1), func.SetLineWidth(1),
          func.SetLineColor(colors[i])) for i, func in enumerate(funcs)]
        for iY in range(1, 1 + symm[0].GetNbinsY()):
            projs = []
            for i, (s, func) in enumerate(zip(symm, funcs)):
                proj = s.ProjectionX('%s_%d' % (s.GetName(), iY), iY, iY)
                proj.SetLineColor(colors[i])
                proj.SetMarkerColor(colors[i])
                proj.SetMinimum(0)
                proj.SetMaximum(height)
                proj.Fit(func, 'QR')
                projs.append(proj)
            for p in projs:
                p.Draw('same' if i else '')
            c.Print(fileName + '.pdf')

        c.Clear()

        height = 1.1 * max([h.GetMaximum() for h in anti] +
                           [abs(h.GetMinimum()) for y in anti])
        funcs = [next(iter(s.GetListOfFunctions()), None) for s in anti]
        [(func.SetLineStyle(1), func.SetLineWidth(1),
          func.SetLineColor(colors[i])) for i, func in enumerate(funcs)]
        for iY in range(1, 1 + anti[0].GetNbinsY()):
            projs = []
            for i, (s, func) in enumerate(zip(anti, funcs)):
                proj = s.ProjectionX('%s_%d' % (s.GetName(), iY), iY, iY)
                proj.SetLineColor(colors[i])
                proj.SetMinimum(-height)
                proj.SetMaximum(height)
                proj.Fit(func, 'QR')
                projs.append(proj)
            for p in projs:
                p.Draw('same' if i else '')
            c.Print(fileName + '.pdf')

        c.Print(fileName + '.pdf]')
        r.gStyle.SetOptStat(optstat)
        print "Wrote file: %s.pdf" % fileName
Example #25
0
def hadd() :
    return ['hadd', whereami()+'/bin/phaddy'][1]
Example #26
0
	def listOfSteps(self,config) :
		return ([
		supy.steps.printer.progressPrinter()]
		### pile-up reweighting
		+[supy.calculables.other.Target("pileupTrueNumInteractionsBX0",thisSample=config['baseSample'],
                                    target=(supy.whereami()+"/../data/pileup/HT300_Double_R12BCD_true.root","pileup"),
                                    groups=[('SQ',[])]).onlySim()] 

		### acceptance filters
		+self.dijetSteps0()
		+[steps.event.general()]
		+[steps.event.genevent()]
		#+[steps.efficiency.NX(pdfweights=None)]	
		#+[steps.efficiency.NXAcc(indicesAcc=self.AccCuts[-1]['name']+'Indices',pdfweights=None)]	
		+[steps.efficiency.NE(pdfweights=None)]	
	
		+[supy.steps.filters.label('data cleanup'),
		supy.steps.filters.value('primaryVertexFilterFlag',min=1),
		supy.steps.filters.value('physicsDeclaredFilterFlag',min=1).onlyData(),
		supy.steps.filters.value('beamScrapingFilterFlag',min=1),
		supy.steps.filters.value('beamHaloTightFilterFlag',min=1),
		supy.steps.filters.value('hbheNoiseFilterFlag',min=1),
		supy.steps.filters.value('hcalLaserEventFilterFlag',min=1),
		supy.steps.filters.value('ecalLaserCorrFilterFlag',min=1),
		supy.steps.filters.value('eeBadScFilterFlag',min=1),
		supy.steps.filters.value('ecalDeadCellTPFilterFlag',min=1),
		supy.steps.filters.value('trackingFailureFilterFlag',min=1),
		]
		
		### trigger
		+[supy.steps.filters.label("hlt trigger"),
		#steps.trigger.hltFilterWildcard("HLT_HT300_v"),
		#steps.trigger.hltTriggerObjectMultiplicity('hlt2DisplacedHT300L1FastJetL3Filter',min=0),
		#steps.trigger.hltTriggerObjectMultiplicity('hlt2PFDisplacedJetsPt50',min=0),
		#supy.steps.filters.multiplicity('TrigPromptGenQ1',min=2),
		#supy.steps.filters.multiplicity('TrigPromptGenQ2',min=2),
		steps.trigger.hltFilterWildcard("HLT_HT300_DoubleDisplacedPFJet60_v"),
		supy.steps.filters.value('caloHT',min=325),
		#supy.steps.filters.value('mycaloHT',min=325),
		]

		+self.dijetSteps1()
		+self.discs()
		+self.dijetSteps2()
		+[steps.event.general(tag='1')]
		#+[
		#  steps.efficiency.NXReco(pdfweights=None,
		#	  indicesRecoLow='ABCDEFGHIndices0',
		#	  indicesRecoHigh='ABCDEFGHIndices1')
		# ]
		+[
          steps.efficiency.multiplicity(pdfweights=None,
              indicesRecoLow='ABCDEFGHIndices0',
              indicesRecoHigh='ABCDEFGHIndices1')
         ]
		+[
          steps.efficiency.NEReco(pdfweights=None,
              indicesRecoLow='ABCDEFGHIndices0',
              indicesRecoHigh='ABCDEFGHIndices1')
         ]
		)
Example #27
0
 def inputFilesListFile(self, sampleName):
     return "%s/inputFileLists/%s/%s.inputFiles" % (whereami(), self.name, sampleName)
Example #28
0
def lumiEnv(initialize=True) :
    return ". %s/%s %s %s"%(supy.whereami(),
                            supy.sites.lumiEnvScript(),
                            supy.sites.info(key='globalOutputDir'),
                            'true' if initialize else 'false')
Example #29
0
def hadd() :
    return ['hadd', whereami()+'/bin/phaddy'][1]
Example #30
0
def fileName(min, max):
    dir = "%s/%s" % (supy.whereami(), configuration.localpath())
    return '%s/skim_%s.root' % (dir, stem(min, max))
Example #31
0
File: other.py Project: elaird/supy
 def reportCache(self) :
     useTDR = True
     likes = self.likelihoods()
     fileName = '/'.join(self.outputFileName.split('/')[:-1]+[self.name])
     optstat = r.gStyle.GetOptStat()
     if useTDR:
         r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C"%whereami())
         r.setTDRStyle()
     r.gStyle.SetOptStat(0)
     r.gStyle.SetPalette(1)
     c = r.TCanvas()
     utils.tCanvasPrintPdf(c, fileName, False, '[')
     with open(fileName+'.txt', "w") as file :
         print >> file, '\n'.join(str(d) for d in self.populations)
         print >> file
         for key in sorted((set(likes[0]) & set(likes[1]) & set(likes[2])), key = lambda k: -1 if self.name==k else k) :
             if not all(item[key] for item in likes) : continue
             dilutions = [utils.dilution(bins1,bins2) for bins1,bins2 in itertools.combinations([utils.binValues(item[key]) for item in likes],2)]
             print >> file, "\t".join([key.ljust(25)]+["%.4f"%d for d in dilutions])
             h = 1.1*max(item[key].GetMaximum() for item in likes)
             l = r.TLegend(0.75,0.85,0.98,0.98)
             l.SetHeader("Dilutions :  %.3f  %.3f  %.3f"%tuple(dilutions))
             for i,(item,color,pop) in enumerate(zip(likes,[r.kBlack,r.kRed,r.kBlue],self.populations)) :
                 names = {'TridiscriminantWTopQCD':'#Delta',
                          'ProbabilityHTopMasses':'P_{MSD}',
                          'TopRatherThanWProbability':'P_{CSV}',
                          'muMetMt':'M_{T} (GeV)',
                          'elMetMt':'M_{T} (GeV)'
                          }
                 if useTDR:
                     item[key].SetTitle(';%s;probability / bin'%names[key])
                     I = item[key].Integral()
                     item[key].Scale(1./I)
                 else: I = 1
                 item[key].UseCurrentStyle()
                 item[key].SetLineColor(color)
                 item[key].SetLineWidth(2)
                 item[key].SetMaximum(h/I)
                 item[key].SetMinimum(0)
                 if not useTDR: item[key].GetYaxis().SetTitle("pdf")
                 item[key].Draw("hist" + ('same' if i else ''))
                 l.AddEntry(item[key], pop['pre'],'l')
             if not useTDR: l.Draw()
             utils.tCanvasPrintPdf(c, fileName, False)
     c.Clear()
     c.Divide(3,2)
     covs = [self.fromCache([item['pre']], ["_cov_%s_%s"%pair for pair in itertools.combinations(self.dists.keys(),2)], tag = item['tag'])[item['pre']] for item in self.populations]
     for key in (set(covs[0]) & set(covs[1]) & set(covs[2])) :
         if not all(item[key] for item in covs) : continue
         hists = [item[key] for item in covs]
         deps = [utils.dependence(h,limit=1,inSigma=False) for h in hists]
         for i,(h,d,pop) in enumerate(zip(hists,deps,self.populations)) :
             d.SetTitle(pop['pre'])
             c.cd(i+1); h.Draw('colz')
             c.cd(i+4); d.Draw('colz')
         utils.tCanvasPrintPdf(c, fileName, False)
     c.Clear()
     for key in sorted((set(likes[0]) & set(likes[1]) & set(likes[2])), key = lambda k: -1 if self.name==k else k) :
         if not all(item[key] for item in likes) : continue
         for i,j in itertools.combinations(range(3),2) :
             k = next(k for k in range(3) if k not in [i,j])
             templates = [ utils.binValues(likes[ii][key]) for ii in [i,j] ]
             observed = utils.binValues(likes[k][key])
             try:  cs = utils.fractions.componentSolver(observed,templates)
             except: cs = None
             if not cs : continue
             notK = likes[k][key].Clone('bf_not_'+likes[k][key].GetName())
             notK.Reset()
             notK.Add(likes[i][key],likes[j][key],cs.fractions[0],cs.fractions[1])
             dil = utils.dilution(utils.binValues(likes[k][key]),utils.binValues(notK))
             l = r.TLegend(0.75,0.85,0.98,0.98)
             l.SetHeader("Dilution : %.3f"%dil)
             l.AddEntry(likes[k][key], self.populations[k]['pre'], 'l')
             l.AddEntry(notK, 'not '+self.populations[k]['pre'], 'l')
             notK.SetLineStyle(2)
             likes[k][key].Draw('hist')
             notK.Draw('hist same')
             l.Draw()
             utils.tCanvasPrintPdf(c, fileName, False)
     utils.tCanvasPrintPdf(c, fileName, True, ']')
     r.gStyle.SetOptStat(optstat)
Example #32
0
	def __init__(self,indicesAcc='',indicesRecoLow='',indicesRecoHigh='',pdfweights=None):
		for item in ['indicesAcc','indicesRecoLow','indicesRecoHigh','pdfweights']: setattr(self,item,eval(item))
		self.trigweights = pickle.load(open(whereami()+"/../data/trigw"))
		self.flavorMap={1:'uds',2:'uds',3:'uds',4:'c',5:'b',11:'e',13:'mu',1.5:'ud',7:'qmu',7.5:'qmu'}
Example #33
0
    def reportCache(self):
        optStat = r.gStyle.GetOptStat()
        r.gStyle.SetOptStat(0)
        r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C" % whereami())
        r.setTDRStyle()
        self.setup(None)
        for hist in filter(None, self.histsBQN):
            hist.Scale(1. / hist.Integral(0, hist.GetNbinsX() + 1))
        if None in self.histsBQN:
            print '%s.setup() failed' % self.name
            r.gStyle.SetOptStat(optStat)
            return
        fileName = '/'.join(self.outputFileName.split('/')[:-1] +
                            [self.name]) + '.pdf'
        c = r.TCanvas()
        c.Print(fileName + '[')
        leg = r.TLegend(0.18, 0.45, 0.95, 0.75)
        #leg.SetHeader("jet flavor")
        leg.SetFillColor(r.kWhite)
        leg.SetBorderSize(0)
        leg.SetTextFont(42)
        for h in self.histsBQN:
            h.Fill(h.GetBinCenter(1), h.GetBinContent(0))
            h.SetBinContent(0, 0)
        height = 1.1 * max(h.GetMaximum() for h in self.histsBQN)
        for i, (f, color, style) in enumerate(
                zip('BQN', [r.kBlack, r.kRed, r.kBlue], [1, 7, 8])):
            h = self.histsBQN[i]
            h.UseCurrentStyle()
            h.SetTitle(";%s;Probability / %.2f" %
                       (h.GetXaxis().GetTitle().split()[0].replace('jet', ''),
                        (self.binning[2] - self.binning[1]) / self.binning[0]))
            h.SetLineColor(color)
            h.SetLineWidth(2 if style == 1 else 3)
            h.SetLineStyle(style)
            h.SetMaximum(height)
            h.SetMinimum(0)
            h.Draw("hist" + ("same" if i else ""))
            leg.AddEntry(
                h, {
                    "B": "Jets from b quark hadronization",
                    "Q": "Jets from W boson decay",
                    "N": "Other jets"
                }[f], 'l')
        leg.Draw()
        r.gPad.RedrawAxis()

        stamp = r.TText()
        ssize = stamp.GetTextSize()
        stamp.SetTextFont(62)
        stamp.SetTextSize(ssize)
        stamp.DrawTextNDC(0.20, 0.88, "CMS")
        stamp.SetTextFont(52)
        stamp.SetTextSize(0.8 * ssize)
        stamp.DrawTextNDC(0.20, 0.83, "Simulation")
        stamp.SetTextFont(42)
        stamp.SetTextSize(ssize)
        stamp.DrawTextNDC(0.84, 0.96, "(8 TeV)")

        c.Print(fileName)
        c.Print(fileName + ']')
        print 'Wrote : %s' % fileName
        r.gStyle.SetOptStat(optStat)
Example #34
0
 def fileName(self, index=None):
     return "/".join([supy.whereami(), configuration.localpath(), "%d.root" % index])
Example #35
0
    def reportCache(self):
        optStat = r.gStyle.GetOptStat()
        r.gStyle.SetOptStat(0)
        r.gROOT.ProcessLine(".L %s/cpp/tdrstyle.C" % whereami())
        r.setTDRStyle()
        r.tdrStyle.SetPadRightMargin(0.06)
        self.setup(None)
        if not self.hists:
            print '%s.setup() failed' % self.name
            r.gStyle.SetOptStat(optStat)
            return
        fileName = '/'.join(self.outputFileName.split('/')[:-1] +
                            [self.name]) + '.pdf'
        c = r.TCanvas()
        c.Print(fileName + '[')

        stamp = r.TText()
        ssize = stamp.GetTextSize()

        for f in 'BQN':
            leg = r.TLegend(0.31, 0.65, 0.9, 0.95)
            #leg.SetHeader("#eta range")
            leg.SetFillColor(r.kWhite)
            leg.SetBorderSize(0)
            leg.SetTextFont(42)
            for i, (color, style) in enumerate(
                    zip([r.kBlack, r.kRed, r.kBlue], [1, 7, 8])):
                h = self.hists[f + str(i)]
                label = h.GetTitle().split(',')[1].replace("0.000<",
                                                           "").replace(
                                                               "<", " < ")
                letter = h.GetTitle().split(',')[0]
                h.SetTitle(
                    ';#lower[0.2]{p_{#lower[-0.25]{T}}^{meas} (GeV)};#lower[-0.15]{Median log(E^{#lower[0.4]{gen}}/E^{#lower[0.4]{meas}})}'
                )
                h.SetLineColor(color)
                h.SetLineStyle(style)
                h.SetLineWidth(3 if style != 1 else 2)
                h.SetMaximum(0.2)
                h.SetMinimum(-0.2)
                h.Draw("histsame" if i else "hist")
                stamp.SetTextFont(42)
                stamp.SetTextSize(ssize)
                stamp.DrawTextNDC(
                    0.2, 0.2, {
                        'B': 'Jets from b quark hadronization',
                        'Q': 'Jets from W boson decay',
                        'N': 'Other jets'
                    }[letter])
                leg.AddEntry(h, label, 'l')
            leg.Draw()
            r.gPad.RedrawAxis()

            stamp.SetTextFont(62)
            stamp.SetTextSize(ssize)
            stamp.DrawTextNDC(0.16, 0.96, "CMS")
            stamp.SetTextFont(52)
            stamp.SetTextSize(0.8 * ssize)
            stamp.DrawTextNDC(0.27, 0.96, "Simulation")
            stamp.SetTextFont(42)
            stamp.SetTextSize(ssize)
            stamp.DrawTextNDC(0.8, 0.96, "(8 TeV)")

            c.Print(fileName)
        c.Print(fileName + ']')
        print 'Wrote : %s' % fileName
        r.gStyle.SetOptStat(optStat)