import glob, sys, os, string, io, ROOT, math, argparse from ROOT import std parser=argparse.ArgumentParser(description='runs the runReco_mb.C root script for a choosable range of files') parser.add_argument('--file',help='a single file to analyze',type=str,default="") parser.add_argument('--runs',help='a range of run numbers to analyze, either comma separated single runs or a range -',type=str,default="") parser.add_argument('--sim',help='not implemented :)') parser.add_argument('--path',help='the path to a folder where the output files will be written to',default="outfiles/parts",type=str) parser.add_argument('--nokeep',help='dangerous option! Only use when single thread use. overwrites existing files',action='store_const',const=1,default=0) parser.add_argument('--nogain',help='disable gain correction',action='store_const',const=0,default=1) parser.add_argument('--nopart',help='disable splitting of files into junks of 5000 events. be careful. not splitting uses a lot of memory and computing time',action='store_const',const=9999999999,default=5000) parser.add_argument('--norecl',help='disable reclustering',action='store_true') parser.add_argument('--noclcorr',help='disable cluster correction',action='store_true') parser.add_argument('--fC',help='error parameter fC',type=float,default=14) parser.add_argument('--hlp',help='show this help',action='store_true') args=parser.parse_args() if args.hlp: parser.print_help() exit(0) ROOT.gROOT.ProcessLine(".x rootlogon.C") dofname=args.file runs=args.runs nparts=25 sim=args.sim path=args.path overwrite=args.nokeep gaincorr=args.nogain nEvts=args.nopart runList=[] partlist={} colindex = runs.find(",") if colindex > 0: runs = runs.split(",") for i in range(len(runs)) : dashIndex = runs[i].find("-") if dashIndex > 0 : runs[i] = runs[i].split("-") for j in range(int(runs[i][0]), int(runs[i][1])+1) : runList.append(j) if dashIndex < 0 and len(runs) > 1 : runList.append(int(runs[i])) else : dashIndex = runs.find("-") if dashIndex > 0 : runs = runs.split("-") for j in range(int(runs[0]), int(runs[1])+1): runList.append(j) if dashIndex < 0 and len(runs) > 1 : runList = [runs] if dofname!="": oldfnum=0 dofile=open(dofname,'r') for line in dofile: fnum=line[0:4] part=line[5:7] if fnum!=oldfnum: runList.append(int(fnum)) partlist[fnum]=[] partlist[fnum].append(int(part)) oldfnum=fnum RFile=ROOT.TFile() for run in runList: if os.path.isfile("decoded/runC_"+str(run)+".lmd_decoded.root"): print 'datafile ok' else: print 'datafile missing! run:',run continue if os.path.isfile("tpc/FOPI/par/tpc.run"+str(run)+".par"): print 'parfile ok' else: print 'parfile missing! run:',run continue if int(run)>1600: RFile=ROOT.TFile.Open("decoded/runC_"+str(run)+".lmd_decoded.root","read") tree=RFile.Get("tpcEvent") else: fname=glob.glob("outfiles/MC/Cosmics_FopiMC_*"+str(run)+".raw.root") RFile=ROOT.TFile.Open(fname[0],"read") tree=RFile.Get("cbmsim") if tree==None: print "no tree found" RFile.Close() continue nofEvts=tree.GetEntriesFast() print nofEvts os.environ['filenum']=str(run) start=0 i=0 if len(partlist.get(str(run),[]))==0: nparts=int(math.ceil(float(nofEvts)/float(nEvts))) partlist[str(run)]=range(nparts) partlist.get(str(run),[]).sort() for num in range(nparts): stop=start+nEvts # print start,stop # print i, num if os.path.isfile("./stop"): print "the stop file exists. cant go on" exit() if i