예제 #1
0
def main():

	##
	##
	########### Gather input ######################################
	##
	##

	logging.info("creating new sample handler")
	sh_all = ROOT.SH.SampleHandler()

	discoverInput.discover(sh_all, search_directories, "*%s*"%treePrefix  )
	print len(sh_all)

	logging.info("adding my tags defined in discoverInput.py")
	discoverInput.addTags(sh_all)

	ROOT.SH.readSusyMetaDir(sh_all,"$ROOTCOREBIN/data/SUSYTools")

	## Split up samplehandler into per-BG SH's based on tag metadata

	sh_data = sh_all.find("data")
	sh_signal = sh_all.find("signal")
	sh_bg = {}

	sh_bg["qcd"] = sh_all.find("qcd")
	sh_bg["top"] = sh_all.find("top")
	sh_bg["wjets"] = sh_all.find("wjets")
	sh_bg["zjets"] = sh_all.find("zjets")

	######This will be done per samplehandler ############################
	##
	##

	#Creation of output directory names
	outputFileNames = {   
		sh_all: "All",
		sh_data: "Data",
		sh_signal: "Signal",
		sh_bg["qcd"]: "QCD",
		sh_bg["top"]: "Top",
		sh_bg["wjets"]: "WJets",
		sh_bg["zjets"]: "ZJets",
		}

	treesToProcess = []

	for mysamplehandler in [	
								# sh_all,
								# sh_data,
								# sh_bg["qcd"],
								# sh_bg["top"],
								# sh_bg["wjets"],
								sh_bg["zjets"] 
							]:

		# print mysamplehandler

		filesToEventuallyHadd = []

		for sample in mysamplehandler:

			sample_name = sample.getMetaString("sample_name")
			# print sample_name
			dsid = sample_name.split(".")[2]

			if len(treesToProcess) == 0:
				treesToProcess = getListOfTreeNames(sample)

			attachCounters(sample)

			mydir = tmpOutputDirectory

			try:
				os.stat(mydir)
			except:
				os.mkdir(mydir)       

			outputSampleFileName = "%s/%s.root"%(tmpOutputDirectory, dsid)
			filesToEventuallyHadd.append(outputSampleFileName)

			outputSampleFile = ROOT.TFile(outputSampleFileName,"RECREATE")  

			for itree in treesToProcess:
				mysamplehandler.setMetaString("nc_tree", itree)
				mytree =  sample.makeTChain().Clone()
				outputTree = ROOT.addBranch( mytree, getNormFactor(sample) , selection)
				outputTree.Write()

			print "Saved tree %s with %s events . . ." % ( outputTree.GetName(), outputTree.GetEntries() )

			outputSampleFile.Close()


		mydir = outputDirectory
		try:
			os.stat(mydir)
		except:
			os.mkdir(mydir)  
		print 'hadd -O -f %s/%s.root %s'%(outputDirectory, outputFileNames[mysamplehandler], " ".join(filesToEventuallyHadd) )      
		os.system('hadd -O -f %s/%s.root %s'%
			(outputDirectory, outputFileNames[mysamplehandler], " ".join(filesToEventuallyHadd) ) 
			)
예제 #2
0
]

##
##
########### Gather input ######################################
##
##

logging.info("creating new sample handler")
sh_all = ROOT.SH.SampleHandler()

discoverInput.discover(sh_all, search_directories, "*%s*" % treeStream)
print len(sh_all)

logging.info("adding my tags defined in discoverInput.py")
discoverInput.addTags(sh_all)

ROOT.SH.readSusyMetaDir(sh_all, "$ROOTCOREBIN/data/SUSYTools")
ROOT.SH.readSusyMetaDir(sh_all, "$ROOTCOREBIN/data/SUSYTools/mc15_13TeV/")


def main():

    if int(ncores) > 1:
        pool = mp.Pool(processes=ncores)
        pool.map(processTheSH, outputSampleNames)
        pool.close()
        pool.join()
    else:
        for outputSampleName in outputSampleNames:
            processTheSH(outputSampleName)
예제 #3
0

##
##
########### Gather input ######################################
##
##

logging.info("creating new sample handler")
sh_all = ROOT.SH.SampleHandler()

discoverInput.discover(sh_all, search_directories, "*%s*"%treeStream  )
print len(sh_all)

logging.info("adding my tags defined in discoverInput.py")
discoverInput.addTags(sh_all)

ROOT.SH.readSusyMetaDir(sh_all,"$ROOTCOREBIN/data/SUSYTools")
ROOT.SH.readSusyMetaDir(sh_all,"$ROOTCOREBIN/data/SUSYTools/mc15_13TeV/")




def main():

	if int(ncores)>1:
		pool = mp.Pool(processes=ncores)
		pool.map(processTheSH, outputSampleNames)
		pool.close()
		pool.join()
	else: