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 #this script:
0003 #Find which Modules bad in the PCL and which are NOT bad in the DQM (express) (and dumps the info in a txt file)
0004 #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) 
0005 import copy
0006 import re
0007 import sys
0008 from optparse import OptionParser 
0009 
0010 
0011 def findpr(options):
0012     BadModpr=open(options.filenamePR,'r')
0013     bmpr=BadModpr.read()
0014     mod="Module"
0015     pcl="PCLBadModule"
0016     sub="SubDetector"
0017 
0018 
0019     prf =  re.findall(r'(SubDetector.*?\n\n.*?)(?:\n+^$|\Z)',bmpr,re.MULTILINE|re.DOTALL)
0020     prf =list(map(lambda x: re.split('\n+',x),prf))
0021     findpr.prd={}
0022     findpr.pralld={}
0023     # create dictionaries                                                                                                         
0024     prfd={}
0025    
0026     
0027     for k in prf:
0028         for l in k[1:]:
0029             n=re.split("\W+",l)
0030             prfd[n[1]]=(l)
0031         findpr.pralld[k[0]]=prfd
0032         prfd={}
0033             
0034     
0035     findpr.prd=copy.deepcopy(findpr.pralld)
0036     #dictionary with pclbadmodules only     
0037 
0038     for k in findpr.prd.keys():
0039             
0040         for l in findpr.prd[k].keys():
0041             if pcl not in findpr.prd[k][l]:
0042                 findpr.prd[k].pop(l)
0043     
0044     #for k in findpr.pralld:
0045     #    print len(findpr.pralld[k])
0046     return 0
0047 
0048 def findse(options):
0049     BadModse=open(options.filenameSE,'r')
0050     bmse=BadModse.read()
0051 
0052     sub="SubDetector"
0053     
0054     sef =  re.findall(r'(SubDetector.*?\n\n.*?)(?:\n+^$|\Z)',bmse,re.MULTILINE|re.DOTALL)
0055     sef =list(map(lambda x: re.split('\n+',x),sef))
0056     findse.sed={}
0057     
0058     sefd={}
0059     for k in sef:
0060         for l in k[1:]:
0061             n=re.split("\W+",l)
0062             sefd[n[1]]=(l)
0063         findse.sed[k[0]]=sefd
0064         sefd={}
0065       
0066 
0067     
0068     return 0
0069    
0070 
0071     
0072 def printall():
0073     seFile=open('SEinPRBadMod.txt','w')
0074     prFile=open('PCLBadMod.txt','w')
0075     seFile.write("Bad Modules from stream express which are still bad in Prompt Reco\n\n")
0076 
0077     for x in findse.sed:
0078         seFile.write("\n"+x+"\n\n")
0079         for y in findse.sed[x]:
0080             if y in findpr.pralld[x]:
0081                 seFile.write(findpr.pralld[x][y]+"\n")
0082 
0083     
0084     prFile.write("Bad Modules from Prompt Reco (PCLBadModules) that are not bad in Stream Express\n\n")
0085     
0086     for x in findpr.prd:
0087         prFile.write("\n"+x+"\n\n")
0088         for y in findpr.prd[x]:
0089              
0090             if y not in findse.sed[x]:
0091                 
0092                 prFile.write(findpr.prd[x][y]+"\n")
0093     
0094     return 0
0095 
0096 
0097 ############################################
0098 if __name__ == "__main__":
0099     verbose = True
0100     usage = "useage: %prog [options] "
0101     parser = OptionParser(usage)
0102     parser.set_defaults(mode="advanced")
0103     parser.add_option("-p", "--filePR", type="string", dest="filenamePR", help="Get the name of the Prompt Reco file")
0104     parser.add_option("-s", "--fileSE", type="string", dest="filenameSE", help="Get the name of the Stream Express file")
0105 
0106     (options, args) = parser.parse_args()
0107     
0108     MyfilenamePR=findpr(options)
0109     MyfilenameSE=findse(options)
0110     Myprintall=printall()
0111         
0112         
0113