def divideScreener(country, process_num = CONFIG.NUM_MULTIPROCESSING): df_screener = Collector.readFile(country, "Screener") unit_size = int(len(df_screener) / process_num) for i in range(process_num): start_num = i * unit_size end_num = (i+1) * unit_size if i != process_num - 1: df = df_screener.iloc[start_num:end_num, :] else: df = df_screener.iloc[start_num:, :] Collector.saveFile(country, df, "Screener_" + str(i+1))
def __init__(self, skipHadd=False, haddAllSamples=False, haddDataSamples=False, skipComponentHadd=False): self.moduleList = [] self.collector = Collector() self.hadder = Hadder() self.skipHadd = skipHadd self.haddAllSamples = haddAllSamples self.haddDataSamples = haddDataSamples self.allSampleName = "AllSample" self.allDataName = "Data" self.skipComponentHadd = skipComponentHadd
rebin = 3 # ____________________________________________________________________________________________________________________________________________ || parser = argparse.ArgumentParser() parser.add_argument("--inputDir",action="store") parser.add_argument("--outputDir",action="store") parser.add_argument("--verbose",action="store_true") option = parser.parse_args() # ____________________________________________________________________________________________________________________________________________ || outputInfo.outputDir = option.inputDir outputInfo.TFileName = "ClosureTest.root" # ____________________________________________________________________________________________________________________________________________ || collector = Collector() collector.makeSampleList(componentList) collector.makeMergedSampleList(componentList,mergeSampleDict) collector.openFiles(collector.samples+collector.mergeSamples,outputInfo) # ____________________________________________________________________________________________________________________________________________ || if not os.path.exists(os.path.abspath(option.outputDir)): os.makedirs(os.path.abspath(option.outputDir)) c = ROOT.TCanvas() for var in variables: if option.verbose: print "*"*100 dataHist = collector.getObj(dataSample,var) if option.verbose: print "Data: ",dataHist.Integral() outHist = dataHist.Clone(var+"_shape") outHist.Rebin(rebin) for ibin in range(1,outHist.GetNbinsX()+1):
def getScreener(country): collector = Collector() collector.selectCountry(country) end_page = collector.getHowManyPages() collector.getStocksBasicInfoByRange(1,end_page,country) collector.driver.quit()
def startCrawling(country, process_num): collector = Collector() done = False while done == False: done = collector.crawlingStart(country, process_num)
option = parser.parse_args() # ____________________________________________________________________________________________________________________________________________ || lnSystFilePath = "/home/lucien/UF-PyNTupleRunner/RA5/StatFW/Config/CommonSyst.txt" allSampleDir = "AllSample" fileName = "StatInput.root" setDataToMC = True addMCStat = True sigModel = "SMS-T1qqqqL_1500" if not option.sigModel else option.sigModel fixWidthStr = "%15s" fixWidthFloat = "%15.2f" if option.inputDir: outputInfo.outputDir = option.inputDir # ____________________________________________________________________________________________________________________________________________ || collector = Collector() collector.makeSampleList(componentList) collector.makeMergedSampleList(componentList,mergeSampleDict) collector.openFiles(collector.samples+collector.mergeSamples,outputInfo) # ____________________________________________________________________________________________________________________________________________ || # syst lnSystReader = LogNormalSystReader() commonLnSystematics = lnSystReader.makeLnSyst(lnSystFilePath) if not os.path.exists(os.path.abspath(option.outputDir)): os.makedirs(os.path.abspath(option.outputDir)) binDict = {} inputFileAll = ROOT.TFile(os.path.join(option.inputDir,allSampleDir,fileName)) for k in inputFileAll.GetListOfKeys():
class EndSequence(BaseModule): def __init__(self, skipHadd=False, haddAllSamples=False, haddDataSamples=False, skipComponentHadd=False): self.moduleList = [] self.collector = Collector() self.hadder = Hadder() self.skipHadd = skipHadd self.haddAllSamples = haddAllSamples self.haddDataSamples = haddDataSamples self.allSampleName = "AllSample" self.allDataName = "Data" self.skipComponentHadd = skipComponentHadd def run(self, inputInfo, componentList, mergeSampleDict={}, mergeSigSampleDict={}): self.collector.makeSampleList(componentList) self.collector.makeMergedSampleList(componentList, mergeSampleDict, mergeSigSampleDict) for sampleName in self.collector.mergeSamples + self.collector.mergeSigSamples: self.makedirs(inputInfo.outputDir + sampleName) if not self.skipHadd: if not self.skipComponentHadd: for sampleName in self.collector.samples: print "Hadding " + sampleName self.makedirs(inputInfo.outputDir + sampleName) self.hadder.makeHaddScript( inputInfo.outputDir + sampleName, [sampleName], inputInfo) self.hadder.haddSampleDir(inputInfo.outputDir + sampleName) if self.haddAllSamples: print "Hadding " + self.allSampleName self.makedirs(inputInfo.outputDir + self.allSampleName) self.hadder.makeHaddScript( inputInfo.outputDir + self.allSampleName, self.collector.samples, inputInfo) self.hadder.haddSampleDir(inputInfo.outputDir + self.allSampleName) if self.haddDataSamples and self.collector.dataSamples: print "Hadding " + self.allDataName self.makedirs(inputInfo.outputDir + self.allDataName) self.hadder.makeHaddScript( inputInfo.outputDir + self.allDataName, self.collector.dataSamples, inputInfo) self.hadder.haddSampleDir(inputInfo.outputDir + self.allDataName) for sampleName in self.collector.mergeSamples + self.collector.mergeSigSamples: print "Hadding (and merging) " + sampleName if sampleName in self.collector.mergeSamples: tmpDict = self.collector.mergeSampleDict elif sampleName in self.collector.mergeSigSamples: tmpDict = self.collector.mergeSigSampleDict self.hadder.makeHaddScript(inputInfo.outputDir + sampleName, tmpDict[sampleName], inputInfo) self.hadder.haddSampleDir(inputInfo.outputDir + sampleName) self.collector.openFiles(self.collector.samples, inputInfo) self.collector.openFiles(self.collector.mergeSamples, inputInfo) self.collector.openFiles(self.collector.mergeSigSamples, inputInfo) if self.haddAllSamples: self.collector.openFiles([ self.allSampleName, ], inputInfo) if self.haddDataSamples: self.collector.openFiles([ self.allDataName, ], inputInfo) for module in self.moduleList: module(self.collector) self.collector.closeFiles() def add(self, module): self.moduleList.append(module) def __len__(self): return len(self.moduleList) def __getitem__(self, index): if index >= len(self): raise IndexError else: return self.moduleList[index]