-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdumpBkgPdfs.py
65 lines (56 loc) · 2.33 KB
/
dumpBkgPdfs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# macro to simplify background fitting procedures
from ROOT import *
printInfo = True
extLibs = ['libdiphotonsUtils', 'libHiggsAnalysisCombinedLimit', 'libdiphotonsRooUtils', 'libflashggFinalFitBackground']
for lib in extLibs:
gSystem.Load(lib)
pdfFactory = PdfModelBuilder()
xVar = RooRealVar("x", "x", 700, 4700)
xVar.setBins(4000)
pdfFactory.setObsVar(xVar)
def getPdfTypes():
return ["DijetSimple", "Dijet" , "VVdijet" , "Atlas" , "Expow" , "Chebychev" , "Exponential", "PowerLaw" , "Laurent"]
def getPdf(name, ext, order):
if name=="DijetSimple":
return pdfFactory.getDijetSimple( "%s_dijetsimple%i" % (ext, order), order)
if name=="Dijet":
return pdfFactory.getDijet( "%s_dijet%i" % (ext, order), order)
if name=="VVdijet":
return pdfFactory.getVVdijet( "%s_vvdijet%i" % (ext, order), order)
if name=="Atlas":
return pdfFactory.getAtlas( "%s_atlas%i" % (ext, order), order)
if name=="Expow":
return pdfFactory.getExpow( "%s_expow%i" % (ext, order), order)
if name=="Chebychev":
return pdfFactory.getChebychev( "%s_cheb%i" % (ext, order), order)
if name=="Exponential":
return pdfFactory.getExponentialSingle( "%s_exp%i" % (ext, order), order)
if name=="PowerLaw":
return pdfFactory.getPowerLawSingle( "%s_pow%i" % (ext, order), order)
if name=="Laurent":
return pdfFactory.getLaurentSeries( "%s_lau%i" % (ext, order), order)
pdfs=[]
for name in getPdfTypes():
for order in range(1, 4):
if getPdf(name, "bkg", order):
pdfs.append(getPdf(name, "bkg", order))
if printInfo:
print "\n\n\n"
print "------- Info about the Vgamma background pdfs -------"
xVar.Print()
info = {}
for pdf in pdfs:
print "------------"
print "this pdf has name %s" % pdf.GetName()
pdf.Print()
#if "dumpFormula" in dir(pdf):
#pdf.dumpFormula()
#else:
#print "no dumpFormula() available for this pdf"
#print " --> this pdf has things named", dir(pdf)
print "------------------------------------------------------"
outWorkspace = RooWorkspace("Vg")
getattr(outWorkspace, 'import')(xVar, RooCmdArg()) # https://sft.its.cern.ch/jira/browse/ROOT-6785
for pdf in pdfs:
getattr(outWorkspace, 'import')(pdf, RooCmdArg())
outWorkspace.SaveAs("bkg_pdfs.root")