import os,sys,glob,argparse def makeanacomm(text): return 'python FOPI/mberger/analyseFOPIReco_cosmics2.py '+actpath+'/Cosmics_FopiMC_86ar85_1'+text+'.reco.root --outfname '+actpath+'/Cosmics_FopiMC_86ar85_1'+text+'.hists.root' parser=argparse.ArgumentParser(description='analyze cosmics from ana file') parser.add_argument('distpath',help='path to the folder with all the distmaps to run',type=str) parser.add_argument('outpath',help='path to save all the output stuff',type=str) parser.add_argument('--nevts',help='number of events to do',type=int,default=10000) parser.add_argument('--mc',help='do mc',action='store_true') parser.add_argument('--digi',help='do digi',action='store_true') parser.add_argument('--reco',help='do reco',action='store_true') parser.add_argument('--recl',help='do recl reco',action='store_true') parser.add_argument('--clcorr',help='do clcorr reco',action='store_true') parser.add_argument('--reclcorr',help='dor clcorr and recl',action='store_true') parser.add_argument('--doit',help='actually really do the stuff',action='store_true') args=parser.parse_args() distmaps=glob.glob(args.distpath+'/*merged.txt') command=[] #anacomm=[] for dmap in distmaps: basename=dmap.split('/')[-1] basename=basename[0:basename.find('_merged.txt')] actpath=args.outpath+'/'+basename os.system('mkdir '+actpath) if args.mc: command.append('root -l macro/tpc/FOPI/runMCFOPICosmics.C\(86,\\"ar\\",85,\\"'+actpath+'\\",'+str(args.nevts)+'\) -q') if args.digi: command.append('root -l macro/tpc/FOPI/runDigiFOPICosmics.C\(\\"'+actpath+'/Cosmics_FopiMC_86ar85_1.mc.root\\",86,\\"ar\\",85,\\"'+dmap+'\\"\) -q') recobase='root -l FOPI/runRecoFOPI_MC_mb_recl_clcorr.C\(\\"'+actpath+'/Cosmics_FopiMC_86ar85_1.raw.root\\",86,\\"ar\\",85,1,0,' if args.reco: command.append(recobase+'false,false\) -q') command.append(makeanacomm('')) if args.recl: command.append(recobase+'false,true\) -q') command.append(makeanacomm('_recl')) if args.clcorr: command.append(recobase+'true,false\) -q') command.append(makeanacomm('_clcorr')) if args.reclcorr: command.append(recobase+'true,true\) -q') command.append(makeanacomm('_recl_clcorr')) for c in command: if args.doit: os.system(c) else: print c