CMS 3D CMS Logo

findBadModT9.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 #this script:
3 #Find which Modules bad in the PCL and which are NOT bad in the DQM (express) (and dumps the info in a txt file)
4 #Find which modules are bad in the DQM (express) and which are still bad in DQM prompt (not because they are masked) (and dumps the info in a txt file)
5 import copy
6 import re
7 import sys
8 from optparse import OptionParser
9 
10 
11 def findpr(options):
12  BadModpr=open(options.filenamePR,'r')
13  bmpr=BadModpr.read()
14  mod="Module"
15  pcl="PCLBadModule"
16  sub="SubDetector"
17 
18 
19  prf = re.findall(r'(SubDetector.*?\n\n.*?)(?:\n+^$|\Z)',bmpr,re.MULTILINE|re.DOTALL)
20  prf =list(map(lambda x: re.split('\n+',x),prf))
21  findpr.prd={}
22  findpr.pralld={}
23  # create dictionaries
24  prfd={}
25 
26 
27  for k in prf:
28  for l in k[1:]:
29  n=re.split("\W+",l)
30  prfd[n[1]]=(l)
31  findpr.pralld[k[0]]=prfd
32  prfd={}
33 
34 
35  findpr.prd=copy.deepcopy(findpr.pralld)
36  #dictionary with pclbadmodules only
37 
38  for k in findpr.prd.keys():
39 
40  for l in findpr.prd[k].keys():
41  if pcl not in findpr.prd[k][l]:
42  findpr.prd[k].pop(l)
43 
44  #for k in findpr.pralld:
45  # print len(findpr.pralld[k])
46  return 0
47 
48 def findse(options):
49  BadModse=open(options.filenameSE,'r')
50  bmse=BadModse.read()
51 
52  sub="SubDetector"
53 
54  sef = re.findall(r'(SubDetector.*?\n\n.*?)(?:\n+^$|\Z)',bmse,re.MULTILINE|re.DOTALL)
55  sef =list(map(lambda x: re.split('\n+',x),sef))
56  findse.sed={}
57 
58  sefd={}
59  for k in sef:
60  for l in k[1:]:
61  n=re.split("\W+",l)
62  sefd[n[1]]=(l)
63  findse.sed[k[0]]=sefd
64  sefd={}
65 
66 
67 
68  return 0
69 
70 
71 
72 def printall():
73  seFile=open('SEinPRBadMod.txt','w')
74  prFile=open('PCLBadMod.txt','w')
75  seFile.write("Bad Modules from stream express which are still bad in Prompt Reco\n\n")
76 
77  for x in findse.sed:
78  seFile.write("\n"+x+"\n\n")
79  for y in findse.sed[x]:
80  if y in findpr.pralld[x]:
81  seFile.write(findpr.pralld[x][y]+"\n")
82 
83 
84  prFile.write("Bad Modules from Prompt Reco (PCLBadModules) that are not bad in Stream Express\n\n")
85 
86  for x in findpr.prd:
87  prFile.write("\n"+x+"\n\n")
88  for y in findpr.prd[x]:
89 
90  if y not in findse.sed[x]:
91 
92  prFile.write(findpr.prd[x][y]+"\n")
93 
94  return 0
95 
96 
97 
98 if __name__ == "__main__":
99  verbose = True
100  usage = "useage: %prog [options] "
101  parser = OptionParser(usage)
102  parser.set_defaults(mode="advanced")
103  parser.add_option("-p", "--filePR", type="string", dest="filenamePR", help="Get the name of the Prompt Reco file")
104  parser.add_option("-s", "--fileSE", type="string", dest="filenameSE", help="Get the name of the Stream Express file")
105 
106  (options, args) = parser.parse_args()
107 
108  MyfilenamePR=findpr(options)
109  MyfilenameSE=findse(options)
110  Myprintall=printall()
111 
112 
113 
def findse(options)
Definition: findBadModT9.py:48
def printall()
Definition: findBadModT9.py:72
def findpr(options)
Definition: findBadModT9.py:11