# mu_qcd = {} mu_qcd_err = {} mu_allhad = {} mu_allhad_err = {} mu_nonallhad2b = {} mu_nonallhad2b_err = {} mu_nonallhad4b = {} mu_nonallhad4b_err = {} muFile = open( "XhhResolved/data/mu_qcd_" + tag + "Tag" + o.weightSet + o.iteration + ".txt", "w") singleTagProbDict = read_mu_qcd_file("XhhResolved/data/singleTagProb_" + tag + "Tag" + o.weightSet + o.iteration + ".txt") newSingleTagProbFile = open( "XhhResolved/data/singleTagProb_" + tag + "Tag" + o.weightSet + str(int(o.iteration) + 1) + ".txt", "w") newSingleTagProb_qcd = {} newSingleTagProb_qcd_err = {} newSingleTagProb_allhad = {} newSingleTagProb_allhad_err = {} def getHists(cut, region, var, mu_cut=""): #allow for different cut for mu calculation baseName = cut + "_" + region + "_" + var + ("_use_mu" if mu_cut else "")
iteration = o.iteration if o.threeTag: tag = "Three" else: tag = "Four" if os.path.exists(o.limitFile): limitFile = ROOT.TFile.Open(o.limitFile, "UPDATE") else: limitFile = ROOT.TFile.Open(o.limitFile, "RECREATE") files = rootFiles.getFiles(iteration,o.nTuple, o.inDir, o.year) muFile = "XhhResolved/data/mu_qcd_"+tag+"Tag_"+o.weights+"_"+o.year+"_"+o.variation+"_"+iteration+".txt" mu_qcd_dict = read_mu_qcd_file(muFile) rebins={} #rebins["m4j_cor_l"] = [100,120,140,160,180,200,220,240,260,280,300,320,340,360,380,400,420,440,460,480, # 500,520,540,560,580,600,640,680,720,820,900,1000,1500] #rebins["m4j_cor_l"] = [100,250,270,290,330,360,400,450,510,580,680,800,1000,1500] rebins["m4j_cor_l"] = [100,120,140,160,180,200,220,240,260,280,300,320,340,360,380,400,420,440,460,480, 500,520,540,560,580,600,640,680,720,820,900,1000,1200] # rebins["m4j_cor_l"] = [100,250,270,350,430, # 510,590,730,1200] #rebins["m4j_cor_l"] = [100,250,270,290,330,360,450,580,800,1500] #rebins["m4j_cor_l"] = [100,250,290,330,360,400,460,530,610,720,850,1500]
if path.exists(o.limitFile): limitFile = TFile.Open(o.limitFile, "UPDATE") else: limitFile = TFile.Open(o.limitFile, "RECREATE") inDir = "hists_" + o.year + "_" + o.weights files = rootFiles.getFiles(o.iteration, o.nTuple, inDir, o.year) shapeVariation = "_CR" #shapeVariation="_CR" if o.doSyst: filesCRw = rootFiles.getFiles(o.iteration, o.nTuple, inDir + shapeVariation, o.year) muFile = "XhhResolved/data/mu_qcd_FourTag_" + o.weights + "_" + o.year + "_" + o.variation + "_" + o.iteration + ".txt" mu_qcd_dict = read_mu_qcd_file(muFile) if o.doSyst: muFileCRw = "XhhResolved/data/mu_qcd_FourTag_" + o.weights + shapeVariation + "_" + o.year + "_" + o.variation + "_" + o.iteration + ".txt" mu_qcd_dictCRw = read_mu_qcd_file(muFileCRw) useAllhad2bShape = True #get files f_data = TFile(files["data"]) f_qcd = TFile(files["qcd"]) f_allhad = TFile(files["allhadShape" if useAllhad2bShape else "allhad"]) f_nonallhad = TFile(files["nonallhad"]) if o.doSyst: f_qcdCRw = TFile(filesCRw["qcd"]) f_allhadCRw = TFile( filesCRw["allhadShape" if useAllhad2bShape else "allhad"])
if not args.is_MC: applyGRL = True # # MC Config # else: applyGRL = False iteration = int(o.iteration) if iteration == 0: m_weightsFile = "" else: m_weightsFile = "$ROOTCOREBIN/data/XhhResolved/weights2bto"+("3" if o.threeTag else "4")+"b_"+o.weights+"_"+o.year+"_"+o.variation+"_"+str(iteration)+".root" m_singleTagProb = 1 if not o.signal and not o.promoteMuons: singleTagProbDict = read_mu_qcd_file("XhhResolved/data/singleTagProb_FourTag_"+o.weights+"_"+o.year+"_"+o.variation+"_"+o.iteration+".txt") m_singleTagProb = singleTagProbDict["singleTagProb_qcd_PassHCdEta"] if o.year == "2016": #if o.allhad: m_singleTagProb = 0.03313746619 #ntuple 02-03-02 if o.allhad: m_singleTagProb = 0.03972047306 #ntuple 02-03-04 if o.year == "2015": #if o.allhad: m_singleTagProb = 0.03011344277 #ntuple 02-03-02 if o.allhad: m_singleTagProb = 0.0422378966 #ntuple 02-03-04 # # Build the Event Data # c.setalg("hh4bEventBuilder", { "m_name" : "hhEventBuilder",