import operator, numpy, os, sys pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/python/argparse-1.2.1') import argparse parser=argparse.ArgumentParser(description='Plot stuff along a track') parser.add_argument('filename',help='filename of the reco file',type=str) parser.add_argument('--ev',help='which event to go to',type=int) parser.add_argument('--events',help='number of events to process',type=int,default=-1) parser.add_argument('--zcut',help='zcut',type=int,default=-80) parser.add_argument('--data',help='analyse real data',action='store_true') parser.add_argument('--pfile',help='the picture file',type=str,default="not") parser.add_argument('--batch',help='batch mode',action='store_true') args=parser.parse_args() import ROOT if args.batch: ROOT.gROOT.SetBatch(True) ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine('gStyle->SetPalette(1)') ROOT.gROOT.ProcessLine('gROOT->SetStyle("Plain")') ROOT.gROOT.LoadMacro("stlPYROOT.h+") rfile=ROOT.TFile.Open(args.filename,"read") if rfile.IsOpen()==ROOT.kTRUE: tree = rfile.Get("cbmsim") if tree==None: print "No cbmsim found" if type(Rfile)==ROOT.TFile: Rfile.Close() exit() tree.SetBranchStatus('*',0) tree.SetBranchStatus('CutCosmics.*',1) zSlices = ( 12.0, 24.0, 36.0, 48.0, 60.0, 73.0 ) #Create Hisogramms--------------------------------------------------------- hcpt = ROOT.TH1D("hcpt", "Cluster per track",45, 0, 45 ) hcpcAll = ROOT.TH1D("hcpcAll", "Cluster per cm", 200, 0,2) #hcpcVsZ = ROOT.TH2D("hcpcVsZ",'Cluster per cm Vs z',75,0,75,200,0,2) hldt = ROOT.TH1D("hldt", "Length of the tracks", 40, 0, 40) hnof = ROOT.TH1D("hnof", "number of tracks", 2,0,2) hdbc = ROOT.TH2D("hdbc", "distance between cluster", 75,0,75,200, 0, 4) hdpcz = ROOT.TH2D("hdpcz", "Digis per Cluster Vs z", 75, 0, 75, 45, 0, 45) hppcz = ROOT.TH2D("hppcz", "Pads per Cluster Vs z", 75, 0, 75, 45, 0, 45) hresz = ROOT.TH2D("hresz", "Residuals Vs z", 75, 0, 75, 2000, -0.1, 0.1) hdpc=[] hcpc=[] hdpcm=[] for i in range(len(zSlices)): hdpc.append(ROOT.TH1D("hdpc{0}".format(i), "Digis per Cluster, {0}st slice".format(i), 45, 0, 45)) hcpc.append(ROOT.TH1D("hcpc{0}".format(i), "Cluster per cm, {0}st slice".format(i), 200, 0, 2)) hdpcm.append(ROOT.TH1D("hdpcm{0}".format(i), "Digis per cm, {0}st slice".format(i), 40, 0, 40)) c1 = ROOT.TCanvas("c1", "Cluster 1", 700,1000) c2 = ROOT.TCanvas("c2", "Cluster 2", 700,1000) c3 = ROOT.TCanvas("c3", "Cluster 3", 1000,700) c4 = ROOT.TCanvas("c4", "Cluster 4", 1000,700) c5 = ROOT.TCanvas("c5", "Cluster 5", 1000,700) c6 = ROOT.TCanvas("c6", "Cluster 6", 700,1000) c7 = ROOT.TCanvas("c7", "Cluster 7", 700,1000) c8 = ROOT.TCanvas("c8", "Cluster 8", 700,1000) c9 = ROOT.TCanvas("c9", "Cluster 9", 700,1000) c1.Divide(1,2) c2.Divide(1,2) c3.Divide(3,2) c4.Divide(3,2) c5.Divide(3,2) c6.Divide(1,2) c7.Divide(1,2) c8.Divide(1,2) c9.Divide(1,2) #------------------------------------------------------------------------- #------------------------------------------------------------------------- oldpos = ROOT.TVector3(0,0,0) evnum = -1 dist = 0 summe_z = 0 digisize = 0 entries = 0 print "events:", tree.GetEntries() for e in tree: evnum += 1 trackindex = -1 if evnum%100==0: print 'Events: {0}'.format(evnum) if e.CutCosmics.GetEntries() == 1: entries = 1 hnof.Fill(entries) if evnum < args.ev: continue if args.events!=-1 and evnum>args.events: break for tr in e.CutCosmics: trackindex += 1 resX=tr.GetResX() resY=tr.GetResY() resZ=tr.GetResZ() resU=tr.GetResU() resV=tr.GetResV() hitIds = tr.GetHitIDs() hitindex=0 if resX.size()==0: continue dist = 0 laenge=0 cluster = 0 dist1 = 0 oldpos = ROOT.TVector3(0,0,0) for ihit in hitIds: cluster +=1 hitindex +=1 if hitindex>=resX.size(): continue #cl=e.TpcCluster.At(clid) pos=tr.GetHitPosition(hitindex) size = tr.GetClusterSize(hitindex) size2D=tr.Get2DClusterSize(hitindex) # print "Y-Pos:", pos.Y() if pos.Z()0: distance = tr.GetClusterDist(hitindex-1) hdbc.Fill(pos.Z(),distance) digisize += size res=tr.GetRes(hitindex) err=tr.GetSigXYZ(hitindex) hresz.Fill(pos.Z(),res.X()) #Digis per Cluster - Fill Histogramm hdpcz.Fill(pos.Z(),size) hppcz.Fill(pos.Z(),size2D) for i in range(len(zSlices)): if pos.Z() 50: #print "*********zu lang:", evnum mw_pos=tr.GetMeanZ() if laenge != 0: cpc = len(hitIds)/laenge else: cpc = -1 if laenge != 0: dpc = gesdigi/laenge else: dpc = 0 #Fill Histogramms---------------------------------------------- hcpt.Fill(len(hitIds)) hcpcAll.Fill(cpc) hldt.Fill(laenge) # hnof.Fill(entries) #hdpcz.Fill(pos.Z(), dpc) for i in range(len(zSlices)): if mw_pos