import ROOT,os def pion_histos(rangefile): histsdict={} ranges=getRanges(rangefile) def TH2D(n,t,xb,xl,xh,yb,yl,yh): return makeTH2D(n,t,xb,xl,xh,yb,yl,yh,ranges) def TH1D(n,t,b,l,h): return makeTH1D(n,t,b,l,h,ranges) hxybinning=110 hxymin=-55 hxymax=55 hzbinning=260 hzmin=-50 hzmax=160 hxybinningTpc=64 hzbinningTpc=160 histsdict['fitflag'] = TH1D("hfitflag","Fitflag",5,0,5) histsdict['hxyz'] = ROOT.TH3D("hxyz","xyz",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,-30,160) histsdict['hxyzTpc'] = ROOT.TH3D("hxyzTpc","xyz Tpc",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) histsdict['hxyzTpcOnly'] = ROOT.TH3D("hxyzTpcOnly","xyz Tpc",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hres={} hres['hxyz res' ] = ROOT.TH3D("hxyzres" , "xyz res ;X(cm);Y(cm);Z(cm)",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,hzmin,hzmax) hres['hxyz resY'] = ROOT.TH3D("hxyzresY", "xyz resY ;X(cm);Y(cm);Z(cm)",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,hzmin,hzmax) hres['hxyz resZ'] = ROOT.TH3D("hxyzresZ", "xyz resZ ;X(cm);Y(cm);Z(cm)",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,hzmin,hzmax) hres['hxyz resU'] = ROOT.TH3D("hxyzresU", "xyz Res U ;X(cm);Y(cm);Z(cm)",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,hzmin,hzmax) hres['hxyz resV'] = ROOT.TH3D("hxyzresV", "xyz Res V ;X(cm);Y(cm);Z(cm)",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,hzmin,hzmax) hres['hxyz resA1'] = ROOT.TH3D("hxyzresA1", "xyz Res A1;X(cm);Y(cm);Z(cm)",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,hzmin,hzmax) hres['hxyz resA2'] = ROOT.TH3D("hxyzresA2", "xyz Res A2;X(cm);Y(cm);Z(cm)",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,hzmin,hzmax) hres['hxyz resA3'] = ROOT.TH3D("hxyzresA3", "xyz Res A3;X(cm);Y(cm);Z(cm)",hxybinning,-55.,55.,hxybinning,-55.,55.,hzbinning,hzmin,hzmax) histsdict["residuals"]=hres hresTpc={} hresTpc['hxyz res' ] = ROOT.TH3D("hxyzresTpc" , "xyz res Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpc['hxyz resY'] = ROOT.TH3D("hxyzresYTpc", "xyz resY Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpc['hxyz resZ'] = ROOT.TH3D("hxyzresZTpc", "xyz resZ Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpc['hxyz resU'] = ROOT.TH3D("hxyzresUTpc", "xyz Res U Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpc['hxyz resV'] = ROOT.TH3D("hxyzresVTpc", "xyz Res V Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpc['hxyz resA1'] = ROOT.TH3D("hxyzresA1Tpc", "xyz Res A1 Tpc;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpc['hxyz resA2'] = ROOT.TH3D("hxyzresA2Tpc", "xyz Res A2 Tpc;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpc['hxyz resA3'] = ROOT.TH3D("hxyzresA3Tpc", "xyz Res A3 Tpc;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) histsdict["residuals Tpc"]=hresTpc hresTpcOnly={} hresTpcOnly['hxyz res' ] = ROOT.TH3D("hxyzresTpcOnly" , "xyz res Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpcOnly['hxyz resY'] = ROOT.TH3D("hxyzresYTpcOnly", "xyz resY Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpcOnly['hxyz resZ'] = ROOT.TH3D("hxyzresZTpcOnly", "xyz resZ Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpcOnly['hxyz resU'] = ROOT.TH3D("hxyzresUTpcOnly", "xyz Res U Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpcOnly['hxyz resV'] = ROOT.TH3D("hxyzresVTpcOnly", "xyz Res V Tpc ;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpcOnly['hxyz resA1'] = ROOT.TH3D("hxyzresA1TpcOnly", "xyz Res A1 Tpc;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpcOnly['hxyz resA2'] = ROOT.TH3D("hxyzresA2TpcOnly", "xyz Res A2 Tpc;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) hresTpcOnly['hxyz resA3'] = ROOT.TH3D("hxyzresA3TpcOnly", "xyz Res A3 Tpc;X(cm);Y(cm);Z(cm)",hxybinningTpc,-16.,16.,hxybinningTpc,-16.,16.,hzbinningTpc,-50,30) histsdict["residuals Tpc Only"]=hresTpcOnly hdedx={} hdedx['tpc'] =TH2D("hdedxtpcVsmom","dE/dx vs mom in TPC;mom(GeV);dE/dx(arbitrary units)",500,0,2,500,0,10000) hdedx['fopi'] =TH2D("hdedxVsmom","dE/dx vs mom;mom(GeV);dE/dx(arbitrary units)",500,0,2,500,0,10000) hdedx['tpc dedx'] =TH1D("hdedxtpc","dE/dx in TPC;dEdx (arbitrary units)",500,0,10000) hdedx['dedx'] =TH1D("hdedx","dE/dx;dEdx (arbitrary units)",500,0,10000) hdedx['mom'] =TH1D("hdedxmom",'momemtum;mom(GeV)',500,0,2) histsdict['dedx']=hdedx nbinsz=18 nbinst=45 hresSurf = {} hresSurf['resX'] = ROOT.TH3D("hSurfresX" , "residual X;Z (cm);Theta (deg);Res (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -1500, 1500) hresSurf['resY'] = ROOT.TH3D("hSurfresY" , "residual Y;Z (cm);Theta (deg);Res (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -1500, 1500) hresSurf['resZ'] = ROOT.TH3D("hSurfresZ" , "residual Z;Z (cm);Theta (deg);Res (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -1500, 1500) hresSurf['resA1'] = ROOT.TH3D("hSurfresA1" , "residual A1;Z (cm);Theta (deg);Res (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -1500, 1500) hresSurf['resA2'] = ROOT.TH3D("hSurfresA2" , "residual A2;Z (cm);Theta (deg);Res (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -1500, 1500) hresSurf['resU'] = ROOT.TH3D("hSurfresU" , "residual U;Z (cm);Theta (deg);Res (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -1500, 1500) hresSurf['resV'] = ROOT.TH3D("hSurfresV" , "residual V;Z (cm);Theta (deg);Res (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -1500, 1500) hresSurf['pullX'] = ROOT.TH3D("hSurfpullX" , "Pull X;Z(cm); #theta (#circ);Pull" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -10 , 10) hresSurf['pullY'] = ROOT.TH3D("hSurfpullY" , "Pull Y;Z(cm); #theta (#circ);Pull" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -10 , 10) hresSurf['pullZ'] = ROOT.TH3D("hSurfpullZ" , "Pull Z;Z(cm); #theta (#circ);Pull" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -10 , 10) hresSurf['pullA1'] = ROOT.TH3D("hSurfpullA1" , "pull A1;Z (cm);Theta (deg);Pull" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -10 , 10) hresSurf['pullA2'] = ROOT.TH3D("hSurfpullA2" , "pull A2;Z (cm);Theta (deg);Pull" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -10 , 10) hresSurf['pullU'] = ROOT.TH3D("hSurfpullU" , "pull U;Z (cm);Theta (deg);Pull" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -10 , 10) hresSurf['pullV'] = ROOT.TH3D("hSurfpullV" , "pull V;Z (cm);Theta (deg);Pull" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, -10 , 10) hresSurf['errX'] = ROOT.TH3D("hSurferrX" , "Error X;Z(cm); #theta (#circ);Error (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, 0 , 600) hresSurf['errY'] = ROOT.TH3D("hSurferrY" , "Error Y;Z(cm); #theta (#circ);Error (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, 0 , 600) hresSurf['errZ'] = ROOT.TH3D("hSurferrZ" , "Error Z;Z(cm); #theta (#circ);Error (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, 0 , 600) hresSurf['errA1'] = ROOT.TH3D("hSurferrA1" , "Error A1;Z (cm);Theta (deg);Error (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, 0 , 600) hresSurf['errA2'] = ROOT.TH3D("hSurferrA2" , "Error A2;Z (cm);Theta (deg);Error (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, 0 , 600) hresSurf['errU'] = ROOT.TH3D("hSurferrU" , "Error U;Z (cm);Theta (deg);Error (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, 0 , 600) hresSurf['errV'] = ROOT.TH3D("hSurferrV" , "Error V;Z (cm);Theta (deg);Error (#mu m)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 100, 0 , 600) hresSurf['clsizeX'] = ROOT.TH3D("hSurfclsizeX" , "Cluster Size X;Z(cm); #theta (#circ);Size (cm)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 200, 0 , 2) hresSurf['clsizeY'] = ROOT.TH3D("hSurfclsizeY" , "Cluster Size Y;Z(cm); #theta (#circ);Size (cm)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 200, 0 , 2) hresSurf['clsizeZ'] = ROOT.TH3D("hSurfclsizeZ" , "Cluster Size Z;Z(cm); #theta (#circ);Size (cm)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 200, 0 , 2) hresSurf['clsizeA1'] = ROOT.TH3D("hSurfclsizeA1" , "Cluster Size A1;Z (cm);Theta (deg);Size (cm)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 200, 0 , 2) hresSurf['clsizeA2'] = ROOT.TH3D("hSurfclsizeA2" , "Cluster Size A2;Z (cm);Theta (deg);Size (cm)" , nbinsz, hzmin, hzmax, nbinst, 0, 180, 200, 0 , 2) histsdict['resSurf'] = hresSurf hresvsZ ={} hresvsZ['cluster track X'] =TH2D("hClusterResXvsZ" ,"Cluster-track Res X vs Z;Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track Y'] =TH2D("hClusterResYvsZ" ,"Cluster-track Res Y vs Z;Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track Z'] =TH2D("hClusterResZvsZ" ,"Cluster-track Res Z vs Z;Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-200000,200000) hresvsZ['cluster track X Cut20']=TH2D("hClusterResXvsZcut20","Cluster-track Res X vs Z (R-Cut,Phi-Cut 20);Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track Y Cut20']=TH2D("hClusterResYvsZcut20","Cluster-track Res Y vs Z (R-Cut,Phi-Cut 20);Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track Z Cut20']=TH2D("hClusterResZvsZcut20","Cluster-track Res Z vs Z (R-Cut,Theta-Cut 20);Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track X Cut10']=TH2D("hClusterResXvsZcut10","Cluster-track Res X vs Z (R-Cut,Phi-Cut10);Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track Y Cut10']=TH2D("hClusterResYvsZcut10","Cluster-track Res Y vs Z (R-Cut,Phi-Cut10);Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track Z Cut10']=TH2D("hClusterResZvsZcut10","Cluster-track Res Z vs Z (R-Cut,Theta-Cut10);Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track A0'] =TH2D("hClusterResA0vsZ" ,"Cluster-track Res A0 vs Z;Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,200,-10 ,10) hresvsZ['cluster track A1'] =TH2D("hClusterResA1vsZ" ,"Cluster-track Res A1 vs Z;Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,200,-1000,1000) hresvsZ['cluster track A2'] =TH2D("hClusterResA2vsZ" ,"Cluster-track Res A2 vs Z;Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,200,-1000,1000) hresvsZ['cluster track U'] =TH2D("hClusterResUvsZ" ,"Cluster-track Res U vs Z;Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track V'] =TH2D("hClusterResVvsZ" ,"Cluster-track Res V vs Z;Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track U Cut'] =TH2D("hClusterResUvsZcut" ,"Cluster-track Res U vs Z (R-Cut);Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) hresvsZ['cluster track V Cut'] =TH2D("hClusterResVvsZcut" ,"Cluster-track Res V vs Z (R-Cut);Z (cm); Res (#mu m)" ,hzbinning,hzmin,hzmax,400,-2000,2000) histsdict['res vs Z']=hresvsZ #other crap histsdict['hslices'] = TH1D("hslices","slicepos",6,0.,6.) return histsdict def cosmic_hslices(zSlices,rangefile): resbins=1000 rebin1=30 rebin2=40 rebin3=50 cSlices = (3,6,9,12,15,18,21,24,50) rSlices = (6.6,8.2,9.8,11.4,13,15) xySlices = (-10,-5,0,5,10,20) cpSlices = (7,14,21,28,35,42) thSlices = (90,95,100,105,110,120) phiSlices = (30,60,90,120,150,180) hslices={} return hslices def getRanges(rangefile): ranges={} if rangefile!='' and os.path.isfile(rangefile): print 'found rangefile ('+rangefile+')' for line in open(rangefile,'read'): line=line.replace('\n','') line=line.replace(' ','') if line[0]=='#': continue words=line.split(',') print 'setting ranges for {0} to {1} {2}'.format(words[0],words[1],words[2]) ranges[words[0]]=[float(words[1]),float(words[2])] return ranges #def makeTH3D(name,title,xb,xmin,xmax,yb,ymin,ymax,zb,zmin,zmax,ranges): def makeTH2D(name,title,xb,xmin,xmax,yb,ymin,ymax,ranges): yranges=ranges.get(name,[ymin,ymax]) h=ROOT.TH2D(name,title,xb,xmin,xmax,yb,yranges[0],yranges[1]) return h def makeTH1D(name,title,bins,low,high,ranges): lowhigh=ranges.get(name,[low,high]) h=ROOT.TH1D(name,title,bins,lowhigh[0],lowhigh[1]) return h