def main(opts, myDir, datacardPatterns, rootFilePatterns, myMassPoints): postfix = "combination" crabScheduler = "arc" crabOptions = { # "GRID": [ # "ce_white_list = jade-cms.hip.fi", # "ce_white_list = korundi.grid.helsinki.fi", # ] } # run if opts.lepType: raise Exception("LEP type Hybrid CLs not implemented yet for combine") elif opts.lhcType: raise Exception("LHC type Hybrid CLs not implemented yet for combine") elif opts.lhcTypeAsymptotic: combine.produceLHCAsymptotic(opts, myDir, massPoints=myMassPoints, datacardPatterns=datacardPatterns, rootfilePatterns=rootFilePatterns, clsType=combine.LHCTypeAsymptotic(opts), postfix=postfix + "_lhcasy") else: return False return True
def main(opts, myDir, datacardPatterns, rootFilePatterns, myMassPoints): postfix = "combination" crabScheduler = "arc" crabOptions = { # "GRID": [ # "ce_white_list = jade-cms.hip.fi", # "ce_white_list = korundi.grid.helsinki.fi", # ] } # run if opts.lepType: raise Exception("LEP type Hybrid CLs not implemented yet for combine") elif opts.lhcType: raise Exception("LHC type Hybrid CLs not implemented yet for combine") elif opts.lhcTypeAsymptotic: combine.produceLHCAsymptotic( opts, myDir, massPoints = myMassPoints, datacardPatterns = datacardPatterns, rootfilePatterns = rootFilePatterns, clsType = combine.LHCTypeAsymptotic(opts), postfix = postfix+"_lhcasy" ) else: return False return True
def analyseTaskDir(taskDir, scenarioData, scenario, massWhiteList, massPoints): myScenario = None myTanbeta = None mySplit = taskDir.split("_") myScenario = mySplit[2] if myScenario != scenario: # Scenario not requested, do not consider it return myTanbeta = mySplit[4].replace("tanbetascan","") myList = os.listdir(taskDir) for item in myList: if item.startswith("higgsCombineobs_") and item.endswith(".root"): mySplit = item.split(".") myMass = mySplit[len(mySplit)-2].replace("mH","") if len(massWhiteList) > 0: if not myMass in massWhiteList: continue if not myMass in massPoints: massPoints.append(myMass) # Read result myResult = commonLimitTools.Result(myMass) myStatus = CombineTools.parseResultFromCombineOutput(taskDir, myResult, myMass) if myStatus != 6: # 1 obs + 5 exp values # Combine failed myResult.failed = True # Store result myKey = tbtools.constructResultKey(myMass, myTanbeta) if myKey in scenarioData.keys(): raise Exception("Duplicate results for scenario=%s mass=%s tanbeta=%s! Remove wrong ones and then rerun!"%(myScenario, myMass, myTanbeta)) scenarioData[myKey] = {} scenarioData[myKey]["combineResult"] = myResult print "Result found for scenario=%s mass=%s tanbeta=%s"%(myScenario, myMass, myTanbeta)
def analyseTaskDir(taskDir, scenarioData, scenario, massWhiteList, massPoints): myScenario = None myTanbeta = None mySplit = taskDir.split("_") myScenario = mySplit[2] if myScenario != scenario: # Scenario not requested, do not consider it return myTanbeta = mySplit[4].replace("tanbetascan", "") myList = os.listdir(taskDir) for item in myList: if item.startswith("higgsCombineobs_") and item.endswith(".root"): mySplit = item.split(".") myMass = mySplit[len(mySplit) - 2].replace("mH", "") if len(massWhiteList) > 0: if not myMass in massWhiteList: continue if not myMass in massPoints: massPoints.append(myMass) # Read result myResult = commonLimitTools.Result(myMass) myStatus = CombineTools.parseResultFromCombineOutput( taskDir, myResult, myMass) if myStatus != 6: # 1 obs + 5 exp values # Combine failed myResult.failed = True # Store result myKey = tbtools.constructResultKey(myMass, myTanbeta) if myKey in scenarioData.keys(): raise Exception( "Duplicate results for scenario=%s mass=%s tanbeta=%s! Remove wrong ones and then rerun!" % (myScenario, myMass, myTanbeta)) scenarioData[myKey] = {} scenarioData[myKey]["combineResult"] = myResult print "Result found for scenario=%s mass=%s tanbeta=%s" % ( myScenario, myMass, myTanbeta)
def main(opts, settings, myDir): postfix = "taujets" # lepType = True lhcType = True # lhcTypeAsymptotic = True crabScheduler = "arc" crabOptions = { # "GRID": [ # "ce_white_list = jade-cms.hip.fi", # "ce_white_list = korundi.grid.helsinki.fi", # ] } if settings.isLands(): if opts.lepType: lands.generateMultiCrab( opts, myDir, massPoints=settings.getMassPoints( commonLimitTools.LimitProcessType.TAUJETS), datacardPatterns=[ settings.getDatacardPattern( commonLimitTools.LimitProcessType.TAUJETS) ], rootfilePatterns=[ settings.getRootfilePattern( commonLimitTools.LimitProcessType.TAUJETS) ], clsType=lands.LEPType(opts.brlimit, opts.sigmabrlimit, toysPerJob=100, firstSeed=settings.getFirstSeed()), numberOfJobs=10, postfix=postfix + "_lep_toys1k", crabScheduler=crabScheduler, crabOptions=crabOptions) elif opts.lhcType: myVR = None if opts.brlimit: if commonLimitTools.isHeavyHiggs( settings.getMassPoints( commonLimitTools.LimitProcessType.TAUJETS)): raise Exception( "Error: --brlimit is not available for heavy H+! Please use --sigmabrlimit !" ) myVR = { "default": None, # Initially obtained from asymp. limit as min/max of +-2 sigma and observed # After that, with trial and error of hybrid limit (e.g. by looking plot*.gif plots) # Light H+, values calibrated with 2011A, met>50, loose delta phi "80": ("0.001", "0.08", "x1.05"), "90": ("0.001", "0.07", "x1.05"), "100": ("0.001", "0.06", "x1.05"), "120": ("0.0005", "0.04", "x1.05"), "140": ("0.0001", "0.03", "x1.05"), "150": ("0.0001", "0.025", "x1.03"), "155": ("0.0001", "0.02", "x1.03"), "160": ("0.0001", "0.02", "x1.03"), } if opts.sigmabrlimit: myVR = { "default": None, # Initially obtained from asymp. limit as min/max of +-2 sigma and observed # After that, with trial and error of hybrid limit (e.g. by looking plot*.gif plots) # Light H+, values calibrated with 2011A, met>50, loose delta phi "80": ("1", "20", "x1.05"), "90": ("1", "20", "x1.05"), "100": ("0.5", "20", "x1.05"), "120": ("0.5", "20", "x1.05"), "140": ("0.5", "10", "x1.05"), "150": ("0.1", "10", "x1.03"), "155": ("0.1", "10", "x1.03"), "160": ("0.1", "10", "x1.03"), "180": ("0.01", "5", "x1.05"), "190": ("0.01", "5", "x1.05"), "200": ("0.01", "5", "x1.05"), "220": ("0.01", "5", "x1.03"), "250": ("0.01", "5", "x1.03"), "300": ("0.01", "5", "x1.03"), "350": ("0.01", "5", "x1.03"), "400": ("0.005", "1", "x1.03"), "500": ("0.005", "1", "x1.03"), "600": ("0.005", "1", "x1.03"), } lands.generateMultiCrab( opts, myDir, massPoints=settings.getMassPoints( commonLimitTools.LimitProcessType.TAUJETS), datacardPatterns=[ settings.getDatacardPattern( commonLimitTools.LimitProcessType.TAUJETS) ], rootfilePatterns=[ settings.getRootfilePattern( commonLimitTools.LimitProcessType.TAUJETS) ], clsType=lands.LHCType(opts.brlimit, opts.sigmabrlimit, toysCLsb=_ntoysCLsb(), toysCLb=_ntoysCLb(), firstSeed=settings.getFirstSeed(), vR=myVR), numberOfJobs=_njobs(), postfix=postfix + "_lhc_jobs160_sb150_b75", crabScheduler=crabScheduler, crabOptions=crabOptions) elif opts.lhcTypeAsymptotic: lands.produceLHCAsymptotic( opts, myDir, massPoints=settings.getMassPoints( commonLimitTools.LimitProcessType.TAUJETS), datacardPatterns=[ settings.getDatacardPattern( commonLimitTools.LimitProcessType.TAUJETS) ], rootfilePatterns=[ settings.getRootfilePattern( commonLimitTools.LimitProcessType.TAUJETS) ], clsType=lands.LHCTypeAsymptotic(opts.brlimit, opts.sigmabrlimit), postfix=postfix + "_lhcasy") else: return False elif settings.isCombine(): if opts.lepType: raise Exception( "LEP type Hybrid CLs not implemented yet for combine") elif opts.lhcType: raise Exception( "LHC type Hybrid CLs not implemented yet for combine") elif opts.lhcTypeAsymptotic: pfix = postfix + "_lhcasy" if opts.postfix != "": pfix += "_" + opts.postfix combine.produceLHCAsymptotic( opts, myDir, massPoints=settings.getMassPoints( commonLimitTools.LimitProcessType.TAUJETS), datacardPatterns=[ settings.getDatacardPattern( commonLimitTools.LimitProcessType.TAUJETS) ], rootfilePatterns=[ settings.getRootfilePattern( commonLimitTools.LimitProcessType.TAUJETS) ], clsType=combine.LHCTypeAsymptotic(opts), postfix=pfix) else: return False return True
def getCombineResultPassedStatus(opts, brContainer, mHp, tanbeta, resultKey, scen): reuseStatus = False if not brContainer.resultExists(mHp, tanbeta): # Produce cards myPostFix = "lhcasy_%s_mHp%s_tanbetascan%.1f"%(scen,mHp,tanbeta) myPostFixAllMasses = "lhcasy_%s_mHpAll_tanbetascan%.1f"%(scen,tanbeta) myList = os.listdir(".") myList.sort() myResultDir = None myResultFound = False for item in myList: if myPostFix in item or myPostFixAllMasses in item: myResultDir = item if myResultDir != None: myList = os.listdir("./%s"%myResultDir) for item in myList: if item.startswith("higgsCombineobs_m%s"%mHp): f = ROOT.TFile.Open(os.path.join(myResultDir, item)) myTree = f.Get("limit") myValue = array.array('d',[0]) myTree.SetBranchAddress("limit", myValue) myResult = commonLimitTools.Result(mHp) if myTree.GetEntries() != 6: myResult.failed = True else: myResult.failed = False i = 0 while i < myTree.GetEntries(): myTree.GetEvent(i) if i == 0: myResult.expectedMinus2Sigma = myValue[0] elif i == 1: myResult.expectedMinus1Sigma = myValue[0] elif i == 2: myResult.expected = myValue[0] elif i == 3: myResult.expectedPlus1Sigma = myValue[0] elif i == 4: myResult.expectedPlus2Sigma = myValue[0] elif i == 5: myResult.observed = myValue[0] i += 1 myResultFound = True brContainer._readFromDatabase(mHp, tanbeta) brContainer.setCombineResult(mHp, tanbeta, myResult) f.Close() if not myResultFound: massInput = [mHp] postFixInput = myPostFix if opts.gridRunAllMassesInOneJob: if mHp != opts.masspoints[0]: return None massInput = opts.masspoints[:] postFixInput = myPostFixAllMasses # Result does not exist, let's calculate it if opts.gridRunAllMassesInOneJob: for m in opts.masspoints: brContainer.produceScaledCards(m, tanbeta) else: brContainer.produceScaledCards(mHp, tanbeta) # Run Combine if "CMSSW_BASE" in os.environ or opts.creategridjobs: resultContainer = combine.produceLHCAsymptotic(opts, ".", massPoints=massInput, datacardPatterns = brContainer.getDatacardPatterns(), rootfilePatterns = brContainer.getRootfilePatterns(), clsType = combine.LHCTypeAsymptotic(opts), postfix = postFixInput, quietStatus = True) if resultContainer != None and len(resultContainer.results) > 0: result = resultContainer.results[0] # Store result brContainer.setCombineResult(mHp, tanbeta, result) else: print "... Skipping combine (assuming debug is intended; to run combine, do first cmsenv) ..." else: reuseStatus = True #if brContainer.resultExists(mHp, tanbeta): #myContainer = brContainer #else: #raise Exception("No datacards present") if opts.creategridjobs: return None # Print output s = "- mHp=%s, tanbeta=%.1f, sigmaTheory="%(mHp, tanbeta) if brContainer.getResult(mHp, tanbeta)["sigmaTheory"] == None: s += "None" else: s += "%.3f"%brContainer.getResult(mHp, tanbeta)["sigmaTheory"] if brContainer.getFailedStatus(mHp, tanbeta): s += " sigmaCombine (%s)=failed"%resultKey else: s += " sigmaCombine (%s)=%.3f, passed=%d"%(resultKey, brContainer.getCombineResultByKey(mHp, tanbeta, resultKey), brContainer.getPassedStatus(mHp, tanbeta, resultKey)) if not reuseStatus: print s # return limit from combine if brContainer.getFailedStatus(mHp, tanbeta): return None return brContainer.getPassedStatus(mHp, tanbeta, resultKey)
def main(opts, settings, myDir): postfix = "taujets" # lepType = True # lhcType = True lhcTypeAsymptotic = True crabScheduler = "arc" crabOptions = { # "GRID": [ # "ce_white_list = jade-cms.hip.fi", # "ce_white_list = korundi.grid.helsinki.fi", # ] } if settings.isLands(): if opts.lepType: lands.generateMultiCrab( opts, myDir, massPoints = settings.getMassPoints(commonLimitTools.LimitProcessType.TAUJETS), datacardPatterns = [settings.getDatacardPattern(commonLimitTools.LimitProcessType.TAUJETS)], rootfilePatterns = [settings.getRootfilePattern(commonLimitTools.LimitProcessType.TAUJETS)], clsType = lands.LEPType(opts.brlimit,opts.sigmabrlimit,toysPerJob=100,firstSeed=settings.getFirstSeed()), numberOfJobs = 10, postfix = postfix+"_lep_toys1k", crabScheduler=crabScheduler, crabOptions=crabOptions) elif opts.lhcType: myVR = None if opts.brlimit: if commonLimitTools.isHeavyHiggs(settings.getMassPoints(commonLimitTools.LimitProcessType.TAUJETS)): raise Exception("Error: --brlimit is not available for heavy H+! Please use --sigmabrlimit !") myVR = {"default": None, # Initially obtained from asymp. limit as min/max of +-2 sigma and observed # After that, with trial and error of hybrid limit (e.g. by looking plot*.gif plots) # Light H+, values calibrated with 2011A, met>50, loose delta phi "80": ("0.001", "0.08", "x1.05"), "90": ("0.001", "0.07", "x1.05"), "100": ("0.001", "0.06", "x1.05"), "120": ("0.0005", "0.04", "x1.05"), "140": ("0.0001", "0.03", "x1.05"), "150": ("0.0001", "0.025", "x1.03"), "155": ("0.0001", "0.02", "x1.03"), "160": ("0.0001", "0.02", "x1.03"), } if opts.sigmabrlimit: myVR = {"default": None, # Initially obtained from asymp. limit as min/max of +-2 sigma and observed # After that, with trial and error of hybrid limit (e.g. by looking plot*.gif plots) # Light H+, values calibrated with 2011A, met>50, loose delta phi "80": ("1", "20", "x1.05"), "90": ("1", "20", "x1.05"), "100": ("0.5", "20", "x1.05"), "120": ("0.5", "20", "x1.05"), "140": ("0.5", "10", "x1.05"), "150": ("0.1", "10", "x1.03"), "155": ("0.1", "10", "x1.03"), "160": ("0.1", "10", "x1.03"), "180": ("0.01", "5", "x1.05"), "190": ("0.01", "5", "x1.05"), "200": ("0.01", "5", "x1.05"), "220": ("0.01", "5", "x1.03"), "250": ("0.01", "5", "x1.03"), "300": ("0.01", "5", "x1.03"), "350": ("0.01", "5", "x1.03"), "400": ("0.005", "1", "x1.03"), "500": ("0.005", "1", "x1.03"), "600": ("0.005", "1", "x1.03"), } lands.generateMultiCrab( opts, myDir, massPoints = settings.getMassPoints(commonLimitTools.LimitProcessType.TAUJETS), datacardPatterns = [settings.getDatacardPattern(commonLimitTools.LimitProcessType.TAUJETS)], rootfilePatterns = [settings.getRootfilePattern(commonLimitTools.LimitProcessType.TAUJETS)], clsType = lands.LHCType(opts.brlimit,opts.sigmabrlimit,toysCLsb=_ntoysCLsb(),toysCLb=_ntoysCLb(),firstSeed=settings.getFirstSeed(),vR=myVR), numberOfJobs = _njobs(), postfix = postfix+"_lhc_jobs160_sb150_b75", crabScheduler=crabScheduler, crabOptions=crabOptions) elif opts.lhcTypeAsymptotic: lands.produceLHCAsymptotic( opts, myDir, massPoints = settings.getMassPoints(commonLimitTools.LimitProcessType.TAUJETS), datacardPatterns = [settings.getDatacardPattern(commonLimitTools.LimitProcessType.TAUJETS)], rootfilePatterns = [settings.getRootfilePattern(commonLimitTools.LimitProcessType.TAUJETS)], clsType = lands.LHCTypeAsymptotic(opts.brlimit,opts.sigmabrlimit), postfix = postfix+"_lhcasy" ) else: return False elif settings.isCombine(): if opts.lepType: raise Exception("LEP type Hybrid CLs not implemented yet for combine") elif opts.lhcType: raise Exception("LHC type Hybrid CLs not implemented yet for combine") elif opts.lhcTypeAsymptotic: pfix = postfix #+"_lhcasy" if opts.postfix != "": pfix += "_"+opts.postfix combine.produceLHCAsymptotic( opts, myDir, massPoints = settings.getMassPoints(commonLimitTools.LimitProcessType.TAUJETS), datacardPatterns = [settings.getDatacardPattern(commonLimitTools.LimitProcessType.TAUJETS)], rootfilePatterns = [settings.getRootfilePattern(commonLimitTools.LimitProcessType.TAUJETS)], clsType = combine.LHCTypeAsymptotic(opts), postfix = pfix ) else: return False return True