DQM
SiStripMonitorClient
scripts
DeadROCCounter.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
from
__future__
import
print_function
3
from
ROOT
import
TFile, gStyle,gPad ,TObject, TCanvas, TH1, TH1F, TH2F, TLegend, TPaletteAxis, TList, TLine, TAttLine, TF1,TAxis
4
import
re
5
import
sys, string
6
7
def
getRunNumber
(filename):
8
global
runNumber
9
pos=filename.find(
"__"
)
10
runNumber=filename[pos-6:pos]
11
#print runNumber
12
13
def
GetNonZeroOccNumber
(histoname):
14
global
nrocs
15
global
fin
16
nrocs=0
17
histo=fin.Get(histoname)
18
if
not
histo:
19
print
(
"null histo"
)
20
return
21
nx=histo.GetNbinsX()
22
ny=histo.GetNbinsY()
23
for
i
in
range
(1,nx+1):
24
for
j
in
range
(1,ny+1):
25
value=histo.GetBinContent(i,j)
26
if
value>0:
27
nrocs += 1
28
29
nrocs=0
30
fname=sys.argv[1]
31
32
runNumber=
"0"
33
getRunNumber
(fname)
34
35
path=
"DQMData/Run "
+ runNumber +
"/Pixel/Run summary/Clusters/OnTrack/"
36
37
labels=[
"BPix L1: "
,
"BPix L2: "
,
"BPix L3: "
,
"FPix tot: "
]
38
39
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"
]
40
41
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
42
43
DeadROCs=[0,0,0,0]
44
45
fin= TFile(fname)
46
47
#print type(fname)
48
49
outname=
"PixZeroOccROCs_run"
+ runNumber +
".txt"
50
out_file = open(outname,
"w"
)
51
52
out_file.write(
"Pixel Zero Occupancy ROCs \n\n"
)
53
bpixtot=0
54
55
for
k
in
range
(0,4):
56
GetNonZeroOccNumber
(histonames[k])
57
if
k==3: nrocs=nrocs/2
#in FPix the histo is filled twice to have it symmetric
58
DeadROCs[k]=TotROCs[k]-nrocs
59
if
k<3: bpixtot+=DeadROCs[k]
60
tmpstr=labels[k] +
str
(DeadROCs[k])
61
if
k==3: out_file.write(
"\nBPix tot: %i \n"
%bpixtot)
62
out_file.write(
"%s \n"
% tmpstr)
63
64
#count entries to avoid low stat runs
65
clusstr=path+
"charge_siPixelClusters"
66
nclust=fin.Get(clusstr)
67
nent=nclust.GetEntries()
68
69
out_file.write(
"\nNumber of clusters= %i \n"
% nent)
70
71
out_file.close()
72
FastTimerService_cff.range
range
Definition:
FastTimerService_cff.py:34
DeadROCCounter.getRunNumber
def getRunNumber(filename)
Definition:
DeadROCCounter.py:7
str
#define str(s)
Definition:
TestProcessor.cc:53
DeadROCCounter.GetNonZeroOccNumber
def GetNonZeroOccNumber(histoname)
Definition:
DeadROCCounter.py:13
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition:
Utilities.cc:46
Generated for CMSSW Reference Manual by
1.8.16