--- UserCode/OSUT3Analysis/Configuration/scripts/makeCutFlows.py 2013/02/06 00:28:41 1.6 +++ UserCode/OSUT3Analysis/Configuration/scripts/makeCutFlows.py 2013/04/09 21:42:18 1.15 @@ -9,14 +9,13 @@ from OSUT3Analysis.Configuration.process parser = OptionParser() parser = set_commandline_arguments(parser) +(arguments, args) = parser.parse_args() -(options, args) = parser.parse_args() - -if options.localConfig: +if arguments.localConfig: sys.path.append(os.getcwd()) - exec("from " + options.localConfig.rstrip('.py') + " import *") + exec("from " + arguments.localConfig.rstrip('.py') + " import *") -condor_dir = set_condor_output_dir(options) +condor_dir = set_condor_output_dir(arguments) from ROOT import TFile, gROOT, gStyle, gDirectory, TKey @@ -27,7 +26,8 @@ texfile = condor_dir + "/cutFlow.tex" replacements = { ">":"$>$", "<":"$<$", - "eta ":"$\\eta$ ", + " eta ":" $\\eta$ ", + " abs(eta) ":" $|\\eta|$ ", "#":"Num", "\\rightarrow":"{\\rightarrow}", @@ -36,40 +36,31 @@ replacements = { "BCtoE QCD":"BCtoE$ $QCD", - "Pt ":"pt ", - "PT ":"pt ", - "pT ":"pt ", - "pt ":"$p_{T}$ ", - - "Ht ":"HT ", - "ht ":"HT ", - "hT ":"HT ", - "HT ":"$H_{T}$ ", - "tig$H_{T}$ ":"tight ", + " pt ":" $p_{T}$ ", + " ht ":"$H_{T}$ ", - "D0":"d0", "d0":"$d_{0}$", - "MET ":"Met ", - "MEt ":"Met ", - "met ":"Met ", - "Met ":"$\\not\\!\\!{E}_{T}$ ", - - "MHT ":"Mht ", - "MHt ":"Mht ", - "mht ":"Mht ", - "Mht ":"$\\not\\!\\!{H}_{T}$ ", + " MET ":" Met ", + " MEt ":" Met ", + " met ":" Met ", + " Met ":"$\\not\\!\\!{E}_{T}$ ", + + " MHT ":" Mht ", + " MHt ":" Mht ", + " mht ":" Mht ", + " Mht ":"$\\not\\!\\!{H}_{T}$ ", "M_Z" : "$M_{Z}$", "M_mumu" : "$M_{\\mu\\mu}$", "M_ee" : "$M_{ee}$", "M_ll" : "$M_{ll}$", - "|" : "$|$" } secondary_replacements = { "$$<$":"$<" + } @@ -100,7 +91,7 @@ for key in testFile.GetListOfKeys(): channels.append(key2.GetName()) fout = open (texfile, "w") -fout.write ("\\documentclass{article}\n\n") +fout.write ("\\documentclass[a2paper,8pt]{article}\n\n") fout.write ("\\usepackage[landscape,margin=0.15cm]{geometry}\n\n") fout.write ("\\usepackage{multirow}\n\n") fout.write ("\\begin{document}\n\n") @@ -109,25 +100,26 @@ fout.close () firstChannel = True -weight = intLumi / 10000.0 -for dataset in processed_datasets: - dataset_file = "%s/%s.root" % (condor_dir,dataset) - os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", weight)) +#weight = intLumi / 10000.0 +#for dataset in processed_datasets: +# dataset_file = "%s/%s.root" % (condor_dir,dataset) +# fin = TFile (dataset_file) +# flags = fin.Get ("flags") +# noWeights = flags and flags.GetBinContent (1) +# fin.Close () +# if types[dataset] != "data" and not noWeights: +# os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", weight)) +# else: +# os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", 1.0)) for channel in channels: # loop over final states, which each have their own directory - fout = open (texfile, "a") - if not firstChannel: - fout.write ("\\pagebreak\n\n") - firstChannel = False - fout.write ("\\section{" + channel + " channel}\n\n") - fout.close () - + formatted_channel = channel.replace("_"," ") cutFlowArgs = "" selectionArgs = "" minusOneArgs = "" #print hist for dataset in processed_datasets: - dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset) + dataset_file = "%s/%s.root" % (condor_dir,dataset) #print dataset_file cutFlowArgs = cutFlowArgs + " " + dataset_file selectionArgs = selectionArgs + " " + dataset_file @@ -147,23 +139,29 @@ for channel in channels: # loop over fin #make cutFlowTable objects fout = open (texfile, "a") - fout.write ("\\subsection{Cut Flow}\n\n") + if not firstChannel: + fout.write ("\\pagebreak\n\n") + firstChannel = False + fout.write ("\\section*{" + formatted_channel + " channel}\n\n") + fout.write ("\\subsection*{Cut flow}\n\n") fout.close () - os.system("cutFlowTable -l %g %s >> %s" % (intLumi,cutFlowArgs,texfile)) + os.system("cutFlowTable -l %g -m %s >> %s" % (intLumi,cutFlowArgs,texfile)) fout = open (texfile, "a") fout.write ("\\pagebreak\n\n") - fout.write ("\\subsection{Individual Selection}\n\n") + fout.write ("\\section*{" + formatted_channel + " channel}\n\n") + fout.write ("\\subsection*{Individual selection}\n\n") fout.close () os.system("cutFlowTable -l %g %s >> %s" % (intLumi,selectionArgs,texfile)) fout = open (texfile, "a") fout.write ("\\pagebreak\n\n") - fout.write ("\\subsection{Minus One}\n\n") + fout.write ("\\section*{" + formatted_channel + " channel}\n\n") + fout.write ("\\subsection*{Minus one}\n\n") fout.close () os.system("cutFlowTable -l %g %s >> %s" % (intLumi,minusOneArgs,texfile)) -for dataset in processed_datasets: - dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset) - os.remove(dataset_file) +#for dataset in processed_datasets: +# dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset) +# os.remove(dataset_file) #reformat tex files for line in fileinput.FileInput(texfile,inplace=1):