import ROOT, argparse,sys sys.path.append('$PANDAPATH/macro/tpc/FOPI/mberger') from functions import sort_inner, sort_inner2, Drawh, Divideh, fillcutred, plotfullevent from cosmic_histos import * parser=argparse.ArgumentParser(description='analyze cosmics from ana file') parser.add_argument("--branch",help="which branch to use",default="TrackFitStat_0") parser.add_argument("filename",help="the file to analyze") parser.add_argument("--slicef",help='a root file with the slices histo',default="") parser.add_argument("--nEvts",help='number of events to analyze',default=-1,type=int) parser.add_argument("--outfname",help="name of the output file",default="./someAnaFile.root",type=str) parser.add_argument("--drawSingle",help="draw a single histo or dict",default="",type=str) parser.add_argument("--hlp",help="display help",action='store_true') args=parser.parse_args() if args.hlp: parser.print_help() exit(0) ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine('gStyle->SetPalette(1)') ROOT.gROOT.ProcessLine('gROOT->SetStyle("Plain")') histsdict=cosmic_histos() histsopt=cosmic_histopt() canvasopt=cosmic_canvasopt() axlabel=cosmic_axlabel() zSlices = [] if args.slicef!="": print "slicename", args.slicef infiles=ROOT.TFile(args.slicef) zSlices = [] histsdict['hslices'] = infiles.Get("hslices") for k in range(1,7): print histsdict['hslices'].GetBinContent(k) zSlices.append(histsdict['hslices']).GetBinContent(k) else: zSlices = ( -48.0, -36.0, -24.0, -12.0, 0.0, 20.0 ) # cosmic ne #zSlices = ( 20, 30, 40, 49, 57, 70 ) # beam for i in range(len(zSlices)): histsdict['hslices'].SetBinContent(i+1,zSlices[i]) hslices=cosmic_hslices(zSlices) RFile=ROOT.TFile() Rfile = ROOT.TFile.Open(args.filename,"read") tree = Rfile.Get("cbmsim") if tree == None : print "No cbmsim in file", file if type(Rfile)==ROOT.TFile: Rfile.Close() exit() tree.SetBranchStatus("*", 0) #tree.SetBranchStatus(args.branch+".*",1) tree.SetBranchStatus("CutCosmics.*",1) trackbranch=ROOT.TBranch() evt=-1 done=0 olddone=0 if args.nEvts==-1: todoev=tree.GetEntriesFast() else: todoev=args.nEvts for e in tree: evt+=1 if args.nEvts!=-1 and args.nEvts70 and abs(phi)<110: histsdict['hresZ'].Fill(posZ[i],resX[i]) for icl in range(len(resX)): resX[icl]*= 10000 resY[icl]*= 10000 resMcX[icl]*=10000 if abs(phi)>70 and abs(phi)<110: histsdict['hxy res'].Fill(posX[icl],posY[icl],resX[icl]) histsdict['hxy'].Fill(posX[icl],posY[icl]) histsdict['hyz res'].Fill(posZ[icl],posY[icl],resX[icl]) histsdict['hyz'].Fill(posZ[icl],posY[icl]) for j in range(len(zSlices)): if posZ[icl]160): histsdict['hxy resY'].Fill(posX[icl],posY[icl],resY[icl]) histsdict['hxy Y'].Fill(posX[icl],posY[icl]) histsdict['hxz resY'].Fill(posZ[icl],posY[icl],resY[icl]) histsdict['hxz'].Fill(posZ[icl],posY[icl]) for j in range(len(zSlices)): if posZ[icl]0: hist[h].Write() else: if hist.GetEntries()>0: hist.Write() for d in hslices: sdict=hslices[d] for i in range(len(zSlices)): h=sdict[i] if h.GetEntries()>0: h.Write() print 'Histos are written into file:', args.outfname print "Anzahl der Histogramme:", " ", histcounter