qpython 31.08.2016
"""
import facoLib as fl


msg = "testing new function ...\n"


print msg
print fl.combinedRelUncertainty(100, [40., 80], True)

print msg
print fl.combinedUncertainty([40., 80], True)

print msg
x = 4
y = 6
z = 2.1
myDoubleArray = [[0, 1, 2], [x, y, z]]
myHeader = ["this", "stuff", "is great"]
print fl.makeTable("testOutput", myDoubleArray, myHeader, True, "any caption", True)


print msg
print fl.getDictFromJson("WW", "", True)


print msg
print fl.floatToPercent(0.12)

# define the bound of the Signal region
#LowBounds=[0.001,0.02,0.05]
bound1 = 0.01

# template histogram that contains one single bin
hist=rt.TH1D("template","template",1,0,1,)


# hard coded lumi taken from doubleEG. Note that the exact value does not influence the results as we are calculating ratio.
lumivalue = 2610.486


# dictionary for the cross section which depends on the samples and on the systShift
XSWeight_dict = fl.getDictFromJson("CrossSection", "", True)
samples_dict={'NP_overlay_stopTobl_m500_Ctau10': 'central', 'TTJets_SingleLeptFromT': 'central', 'ZZTo2L2Nu': 'central', 'TTJets_Dilept': 'central', 'SingleTop_tW': 'central', 'TTJets_SingleLeptFromTbar': 'central', 'ZG': 'central', 'WJetsToLNu': 'central', 'SingleTop_tbarW': 'central', 'WGToLNuG': 'central', 'ZZTo4Lpowheg': 'central', 'WZTo3LNu': 'central', 'WWTo2l2Nu': 'central', 'WWToLNuQQ': 'central'}

# loop over the channel (lepton in final statue)
for chan in channels:
    

    isElEl=False
    isMuMu=False
    doubleArray=[]

    # get the xmlfile that corresponds to the channel
    if "MuMu" in chan:
        isMuMu=True
        tree = ET.ElementTree(file='../config/MuMuV4.xml')
        FinalState="At least two muons"

# dict with the cst systemtic uncertainties
dict_cstSystType={"lumi":0.05, "trigger_sf_electron":0.20, "trigger_sf_muon":0.10, "trk_sf_electron":0.24, "trk_sf_muon":0.12 }


# lepton dependent syst type
muonSystTypes=["XSWeight", "evt_puSF","sf_iso_muon","sf_id_muon","lumi","trigger_sf_muon", "trk_sf_muon"]
electronSystTypes=["XSWeight", "evt_puSF","sf_reco_electron","sf_id_electron","trigger_sf_electron", "trk_sf_electron"]


# loop over the channels
for chan in ["ElEl", "MuMu"]:

    # dictionary for the cross section which depends on the samples and on the systShift 
    Yield_dict = fl.getDictFromJson(chan, "", True) 
    print "the merged dict is \n"
    print Yield_dict


    if "ElEl" in chan:
        isElEl=True
	tree = ET.ElementTree(file='../config/ElElV4.xml')
	FinalState="At least two electrons"
        print FinalState
        systTypes=list(electronSystTypes)

    elif "MuMu" in chan:
        isMuMu=True
        tree = ET.ElementTree(file='../config/MuMuV4.xml')
        FinalState="At least two muons"