File indexing completed on 2024-11-26 02:34:10
0001
0002 from ROOT import TFile, gStyle,gPad ,TObject, TCanvas, TH1, TH1F, TH2F, TLegend, TPaletteAxis, TList, TLine, TAttLine, TF1,TAxis
0003 import re
0004 import sys, string
0005
0006 def getRunNumber(filename):
0007 global runNumber
0008 pos=filename.find("__")
0009 runNumber=filename[pos-6:pos]
0010
0011
0012 def GetNonZeroOccNumber(histoname):
0013 global nrocs
0014 global fin
0015 nrocs=0
0016 histo=fin.Get(histoname)
0017 if not histo:
0018 print("null histo")
0019 return
0020 nx=histo.GetNbinsX()
0021 ny=histo.GetNbinsY()
0022 for i in range(1,nx+1):
0023 for j in range(1,ny+1):
0024 value=histo.GetBinContent(i,j)
0025 if value>0:
0026 nrocs += 1
0027
0028 nrocs=0
0029 fname=sys.argv[1]
0030
0031 runNumber="0"
0032 getRunNumber(fname)
0033
0034 path="DQMData/Run " + runNumber +"/Pixel/Run summary/Clusters/OnTrack/"
0035
0036 labels=["BPix L1: ", "BPix L2: ", "BPix L3: ", "FPix tot: "]
0037
0038 histonames=[path + "pix_bar Occ_roc_ontracksiPixelDigis_layer_1",path + "pix_bar Occ_roc_ontracksiPixelDigis_layer_2",path + "pix_bar Occ_roc_ontracksiPixelDigis_layer_3",path + "ROC_endcap_occupancy"]
0039
0040 TotROCs=[2560-256,4096-256,5632-256,4320]
0041
0042 DeadROCs=[0,0,0,0]
0043
0044 fin= TFile(fname)
0045
0046
0047
0048 outname="PixZeroOccROCs_run" + runNumber + ".txt"
0049 out_file = open(outname, "w")
0050
0051 out_file.write("Pixel Zero Occupancy ROCs \n\n")
0052 bpixtot=0
0053
0054 for k in range(0,4):
0055 GetNonZeroOccNumber(histonames[k])
0056 if k==3: nrocs=nrocs/2
0057 DeadROCs[k]=TotROCs[k]-nrocs
0058 if k<3: bpixtot+=DeadROCs[k]
0059 tmpstr=labels[k] + str(DeadROCs[k])
0060 if k==3: out_file.write("\nBPix tot: %i \n" %bpixtot)
0061 out_file.write("%s \n" % tmpstr)
0062
0063
0064 clusstr=path+"charge_siPixelClusters"
0065 nclust=fin.Get(clusstr)
0066 nent=nclust.GetEntries()
0067
0068 out_file.write("\nNumber of clusters= %i \n" % nent)
0069
0070 out_file.close()
0071