if zlFitterConfig.useDDQCDsample:#normWeight is 0 => remove it
    qcdSample.setTreeName("Data_SRAll")
else :
    qcdSample.setTreeName("QCD_SRAll")
qcdSample.setNormFactor("mu_"+zlFitterConfig.qcdSampleName, 1., 0., 50000000.)
qcdSample.setFileList(qcdFiles)
qcdSample.setStatConfig(zlFitterConfig.useStat)

qcdWeight = 1
nJets = channel.nJets
if nJets > 0 and nJets < len(zlFitterConfig.qcdWeightList)+1:
    qcdWeight = zlFitterConfig.qcdWeightList[nJets-1]/ (zlFitterConfig.luminosity)
    if zlFitterConfig.useMCQCDsample:
        qcdWeight = 1

    qcdSample.addWeight(str(qcdWeight))
    for w in configMgr.weights: #add all other weights but not normWeight
        qcdSample.addWeight(w)
    if zlFitterConfig.useDDQCDsample:#normWeight is 0 => remove it
        qcdSample.removeWeight("normWeight")
        qcdSample.removeWeight("eventWeight")
        qcdSample.removeWeight("WZweight")
        qcdSample.removeWeight("1000.")
        # qcdSample.removeWeight("weight")
        qcdSample.addWeight("0.01")


#--------------------------
# QCD Gamma Fakes - for CRY
#--------------------------
qcdGammaFakeSample = Sample(zlFitterConfig.qcdSampleName+"GammaFakes", kOrange+2)
    topSample.addSystematic(jes)
    topSample.addSystematic(jer)
    topSample.addSystematic(scalest)
    topSample.addSystematic(resost)  

if useSyst and useCRWTY:
    #topSample.setNormRegions([("CRT","cuts"),("CRW","cuts")])
    topSample.setNormRegions([("CRT", binVar)])

# QCD
qcdSample = Sample("Multijets", kOrange+2)
qcdSample.setTreeName("QCDdd")
qcdSample.setNormFactor("mu_Multijets", 1., 0., 500.)
qcdSample.setFileList(qcdFiles)
qcdSample.setStatConfig(useStat)
qcdSample.addWeight("0.0000013")#ATT: qcd prenormalisation
## if useSyst :
##     if useQCDMethodSyst:
##         qcdSample.addSystematic(QCDTailSys )
##         qcdSample.addSystematic(QCDGausSys )
##     else:
##         qcdSample.addSystematic(theoSysQCD)

#qcdSample.addSystematic(QCDGausSys)
#qcdSample.addSystematic(QCDTailSys)

if useSyst and useCRQ:
    qcdSample.setNormRegions([("CRQCD", binVar)])

# W 
wSample = Sample("Wjets", kAzure+1)
topSample.setFileList(topFiles)
topSample.setStatConfig(useStat) 
if useTheoSys:
    if useSyst: topSample.addSystematic(theoSysTop)
    ####topSample.addSystematic(mu1ScaleSysTop)
    ####topSample.addSystematic(mu2ScaleSysTop)
    ####topSample.addSystematic(matchScaleSysTop)
topSample.setNormRegions([("CRT","meffInc"),("CRW","meffInc")])


qcdSample = Sample("Multijets",kOrange+2)
qcdSample.setTreeName("QCDdd")
qcdSample.setNormFactor("mu_Multijets",1.,0.,500.)
qcdSample.setFileList(qcdFiles)
qcdSample.setStatConfig(useStat)
qcdSample.addWeight("0.000001")#qcd prenormalisation
#qcdSample.addSystematic(QCDGausSys)
#qcdSample.addSystematic(QCDTailSys)
qcdSample.setNormRegions([("CRQCD","meffInc")])

    
wSample = Sample("Wjets",kAzure+1)
wSample.setTreeName("W_SRAll")
wSample.setNormFactor("mu_W",1.,0.,500.)
wSample.setFileList(wFiles)
wSample.setStatConfig(useStat)
if useTheoSys:
    if useSyst: wSample.addSystematic(mu1ScaleSysW)
    if useSyst: wSample.addSystematic(mu2ScaleSysW)
    if useSyst: wSample.addSystematic(matchScaleSysW)
    if useSyst: wSample.addSystematic(sherpaBugW)
#--------------------------
# QCD
#--------------------------
qcdSample = Sample(zlFitterConfig.qcdSampleName, kOrange+2)
qcdSample.setTreeName("QCD_SRAll")
qcdSample.setNormFactor("mu_"+zlFitterConfig.qcdSampleName, 1., 0., 500.)
qcdSample.setFileList(qcdFiles)
qcdSample.setStatConfig(zlFitterConfig.useStat)

qcdWeight = 1
nJets = channel.nJets
if nJets > 0 and nJets < len(zlFitterConfig.qcdWeightList):
    qcdWeight = zlFitterConfig.qcdWeightList[nJets-1]/ (zlFitterConfig.luminosity)
    # qcdSample.addWeight(str(qcdWeight))
    for w in configMgr.weights: #ATT: there is a bug in HistFitter, I have to add the other weight by hand
        qcdSample.addWeight(w)

if zlFitterConfig.doSetNormRegion:
    if "CRQ" in zlFitterConfig.constrainingRegionsList:
        qcdSample.setNormRegions([("CRQ", zlFitterConfig.binVar)])



# Define samples
#FakePhotonSample = Sample("Bkg",kGreen-9)
#FakePhotonSample.setStatConfig(False)
#FakePhotonSample.buildHisto([nbkg],"UserRegion","cuts")
# ucb = Systematic("ucb", configMgr.weights, 1 + nbkgErr/nbkg, 1 - nbkgErr/nbkg, "user","userOverallSys")
#FakePhotonSample.addSystematic(ucb)