import ROOT,sys,math,os,time,glob,copy,numpy from array import array pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/python/argparse-1.2.1') sys.path.append(pandapath+'/macro/tpc/FOPI/mberger') import argparse from functions import * ROOT.gROOT.ProcessLine(".x rootlogon.C") set_palette() parfile=ROOT.TFile("outfiles_e12/Data/Cosmics/run_3888/run_3888_86_ArCO2_85_recl_clcorr_planeErr_rev28578_paramRev28578_firstIter.param.root","READ") lmdfile=ROOT.TFile("outfiles_e12/runC_3888.lmd_decoded.root","READ") digiPar=parfile.Get('TpcDigiPar') digiMap = ROOT.TpcDigiMapper.getInstance() digiMap.init(digiPar) padplane=digiPar.getPadPlane() hpadplanePed=ROOT.TH2Poly("hpadplanePed","Pedestals;X(cm);Y(cm)",-16,16,-16,16) hpadplaneSig=ROOT.TH2Poly("hpadplaneSig","Sigma;X(cm);Y(cm)",-16,16,-16,16) npads=padplane.GetNPads() print "creating histos" x,y=ROOT.Double(0),ROOT.Double(0) for ipad in range(npads): #apad=ROOT.TpcPad() apad=padplane.GetPad(ipad) nvert=apad.GetNBoundaryPoints()-1 vertX=[] vertY=[] for ivert in range(nvert): apad.GetBoundaryPoint(ivert,x,y) #print ivert,x,y vertX.append(copy.copy(x)) vertY.append(copy.copy(y)) #print array("f",vertX) hpadplanePed.AddBin(nvert,numpy.array(vertX),numpy.array(vertY)) hpadplaneSig.AddBin(nvert,numpy.array(vertX),numpy.array(vertY)) hpedestal=lmdfile.Get("PedestalPadIDGlobalRef") hsigma=lmdfile.Get("SigmaPadIDGlobalRef") minped=500 maxped=0 minsig=200 maxsig=0 print "filling histos" meansig=0 sigcount=0 for ibin in range(hpedestal.GetNbinsX()): ped=hpedestal.GetBinContent(ibin) sig=hsigma.GetBinContent(ibin) if(ped!=0): hpadplanePed.SetBinContent(ibin,ped) minped=min(minped,ped) maxped=max(maxped,ped) if(sig!=0): hpadplaneSig.SetBinContent(ibin,sig) minsig=min(minsig,sig) maxsig=max(maxsig,sig) sigcount+=1 meansig+=sig meansig/=sigcount routfile=ROOT.TFile("/home/mberger/gurkensalat/images/chap_Results/sec_Cuts/pedestals.root","RECREATE") hpadplanePed.Write() hpadplaneSig.Write() routfile.Close() print "drawing histos" c1=ROOT.TCanvas("c1","pedestal",1000,1000) #c1.SetLogz() hpadplanePed.GetZaxis().SetRangeUser(minped,maxped) hpadplanePed.SetStats(0) hpadplanePed.Draw("colz") c2=ROOT.TCanvas("c2","sigma",1000,1000) #c2.SetLogz() hpadplaneSig.GetZaxis().SetRangeUser(minsig,maxsig) hpadplaneSig.SetStats(0) hpadplaneSig.Draw("colz") print "the average width is:",meansig print "amount of usable channels:",100*float(sigcount)/float(npads),"% npads=",npads," usable=",sigcount," dead=",npads-sigcount thisIsTheEnd()