Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-07 22:33:03

0001 #!/usr/bin/env python3
0002 from __future__ import print_function
0003 from ROOT import TFile, gStyle,gPad ,TObject, TCanvas, TH1, TH1F, TH2F, TLegend, TPaletteAxis, TList, TLine, TAttLine, TF1,TAxis
0004 import re
0005 import sys, string
0006 
0007 def getRunNumber(filename):
0008     global runNumber
0009     pos=filename.find("__")
0010     runNumber=filename[pos-6:pos]
0011     #print runNumber
0012 
0013 def GetNonZeroOccNumber(histoname):
0014     global nrocs
0015     global fin
0016     nrocs=0
0017     histo=fin.Get(histoname)
0018     if not histo:
0019         print("null histo")
0020         return
0021     nx=histo.GetNbinsX()
0022     ny=histo.GetNbinsY()
0023     for i in range(1,nx+1):
0024         for j in range(1,ny+1):
0025             value=histo.GetBinContent(i,j)
0026             if value>0:
0027                 nrocs += 1
0028 
0029 nrocs=0
0030 fname=sys.argv[1]
0031 
0032 runNumber="0"
0033 getRunNumber(fname)
0034 
0035 path="DQMData/Run " + runNumber +"/Pixel/Run summary/Clusters/OnTrack/"
0036 
0037 labels=["BPix L1: ", "BPix L2: ", "BPix L3: ", "FPix tot: "]
0038 
0039 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"]
0040 
0041 TotROCs=[2560-256,4096-256,5632-256,4320] #total number of ROCs in the Pixel detector layers and the FPix, the factor 256 for BPix Layer derive by half modules, left there as a reminder
0042 
0043 DeadROCs=[0,0,0,0]
0044 
0045 fin= TFile(fname)
0046 
0047 #print type(fname)
0048 
0049 outname="PixZeroOccROCs_run" + runNumber + ".txt"
0050 out_file = open(outname, "w")
0051 
0052 out_file.write("Pixel Zero Occupancy ROCs \n\n")
0053 bpixtot=0
0054 
0055 for k in range(0,4):
0056     GetNonZeroOccNumber(histonames[k])
0057     if k==3: nrocs=nrocs/2 #in FPix the histo is filled twice to have it symmetric
0058     DeadROCs[k]=TotROCs[k]-nrocs
0059     if k<3: bpixtot+=DeadROCs[k]
0060     tmpstr=labels[k] + str(DeadROCs[k])
0061     if k==3: out_file.write("\nBPix tot: %i \n" %bpixtot)   
0062     out_file.write("%s \n" % tmpstr)
0063 
0064 #count entries to avoid low stat runs
0065 clusstr=path+"charge_siPixelClusters"
0066 nclust=fin.Get(clusstr)
0067 nent=nclust.GetEntries()
0068 
0069 out_file.write("\nNumber of clusters=  %i \n" % nent)
0070 
0071 out_file.close()    
0072