File indexing completed on 2024-11-25 02:29:10
0001 import xml.etree.ElementTree as ET
0002 import sys
0003
0004
0005 TARGET_LIST_OF_TAGS=['BeamSpotObject_ByLumi',
0006 'BeamSpotObject_ByRun',
0007 'BeamSpotObjectHP_ByLumi',
0008 'BeamSpotObjectHP_ByRun',
0009 'SiPixelLA_pcl',
0010 'SiPixelLAMCS_pcl',
0011 'SiPixelQualityFromDbRcd_other',
0012 'SiPixelQualityFromDbRcd_prompt',
0013 'SiPixelQualityFromDbRcd_stuckTBM',
0014 'SiStripApvGain_pcl',
0015 'SiStripApvGainAAG_pcl',
0016 'SiStripBadStrip_pcl',
0017 'SiStripBadStripRcdHitEff_pcl',
0018 'SiStripLA_pcl',
0019 'SiPixelAli_pcl',
0020 'SiPixelAliHG_pcl',
0021 'SiPixelAliHGCombined_pcl']
0022 TARGET_DQM_FILES=1
0023 TARGET_DQM_FILENAME='./DQM_V0001_R000325022__Express__PCLTest__ALCAPROMPT.root'
0024 TARGET_DB_FILES=len(TARGET_LIST_OF_TAGS)
0025 TARGET_DB_FILENAME='sqlite_file:testPCLAlCaHarvesting.db'
0026 TARGET_XML_FILENAME='testPCLAlCaHarvesting.xml'
0027 TOTAL_TARGET_FILES=TARGET_DQM_FILES+TARGET_DB_FILES
0028
0029
0030 def parseXML(xmlfile):
0031
0032
0033 tree = ET.parse(xmlfile)
0034
0035
0036 root = tree.getroot()
0037
0038 totAnaEntries=len(root.findall('AnalysisFile'))
0039
0040 if(totAnaEntries!=TOTAL_TARGET_FILES):
0041 print("ERROR: found a not expected number (",totAnaEntries,") of AnalysisFile entries in the FrameworkJobReport.xml, expecting",TOTAL_TARGET_FILES)
0042 return -1
0043
0044 listOfInputTags=[]
0045
0046 countDBfiles=0
0047 countDQMfiles=0
0048
0049
0050 for item in root.findall('AnalysisFile'):
0051
0052 for child in item:
0053 if(child.tag == 'FileName'):
0054 if(child.text==TARGET_DB_FILENAME):
0055 countDBfiles+=1
0056 elif(child.text==TARGET_DQM_FILENAME):
0057 countDQMfiles+=1
0058 else:
0059 pass
0060 if(child.tag == 'inputtag'):
0061 listOfInputTags.append(child.attrib['Value'])
0062
0063 if(countDBfiles!=TARGET_DB_FILES):
0064 print("ERROR! Found an unexpected number of DB files (",countDBfiles,")")
0065 return -1
0066
0067 if(countDQMfiles!=TARGET_DQM_FILES):
0068 print("ERROR! Found an uexpected number of DQM files (",countDQMfiles,")")
0069 return -1
0070
0071
0072 listOfInputTags.sort()
0073 TARGET_LIST_OF_TAGS.sort()
0074
0075
0076 if(listOfInputTags!=TARGET_LIST_OF_TAGS):
0077 print(" list of input tags found in file:",listOfInputTags)
0078 print(" target list of tags:",TARGET_LIST_OF_TAGS)
0079
0080 if (listOfInputTags>TARGET_LIST_OF_TAGS):
0081 print("ERROR!\n This ",[x for x in TARGET_LIST_OF_TAGS if x not in listOfInputTags]," is the set of expected tags not found in the FwdJobReport!")
0082 else:
0083 print("ERROR!\n This ",[x for x in listOfInputTags if x not in TARGET_LIST_OF_TAGS]," is the set of tags found in the FwkJobReport, but not expected!")
0084 return -1
0085
0086 return 0
0087
0088
0089 def main():
0090 try:
0091 f = open(TARGET_XML_FILENAME)
0092 except IOError:
0093 print("%s is not accessible" % TARGET_XML_FILENAME)
0094 sys.exit(1)
0095
0096
0097 result = parseXML(TARGET_XML_FILENAME)
0098 if(result==0):
0099 print("All is fine with the world!")
0100 sys.exit(0)
0101 else:
0102 print("Parsing the FwkJobReport results in failure!")
0103 sys.exit(1)
0104
0105
0106 if __name__ == "__main__":
0107
0108
0109 main()