File indexing completed on 2024-12-12 23:18:46
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 'SiPixelAliHLTHGCombined_pcl'
0023 ]
0024 TARGET_DQM_FILES=1
0025 TARGET_DQM_FILENAME='./DQM_V0001_R000325022__Express__PCLTest__ALCAPROMPT.root'
0026 TARGET_DB_FILES=len(TARGET_LIST_OF_TAGS)
0027 TARGET_DB_FILENAME='sqlite_file:testPCLAlCaHarvesting.db'
0028 TARGET_XML_FILENAME='testPCLAlCaHarvesting.xml'
0029 TOTAL_TARGET_FILES=TARGET_DQM_FILES+TARGET_DB_FILES
0030
0031
0032 def parseXML(xmlfile):
0033
0034
0035 tree = ET.parse(xmlfile)
0036
0037
0038 root = tree.getroot()
0039
0040 totAnaEntries=len(root.findall('AnalysisFile'))
0041
0042 if(totAnaEntries!=TOTAL_TARGET_FILES):
0043 print("ERROR: found a not expected number (",totAnaEntries,") of AnalysisFile entries in the FrameworkJobReport.xml, expecting",TOTAL_TARGET_FILES)
0044 return -1
0045
0046 listOfInputTags=[]
0047
0048 countDBfiles=0
0049 countDQMfiles=0
0050
0051
0052 for item in root.findall('AnalysisFile'):
0053
0054 for child in item:
0055 if(child.tag == 'FileName'):
0056 if(child.text==TARGET_DB_FILENAME):
0057 countDBfiles+=1
0058 elif(child.text==TARGET_DQM_FILENAME):
0059 countDQMfiles+=1
0060 else:
0061 pass
0062 if(child.tag == 'inputtag'):
0063 listOfInputTags.append(child.attrib['Value'])
0064
0065 if(countDBfiles!=TARGET_DB_FILES):
0066 print("ERROR! Found an unexpected number of DB files (",countDBfiles,")")
0067 return -1
0068
0069 if(countDQMfiles!=TARGET_DQM_FILES):
0070 print("ERROR! Found an uexpected number of DQM files (",countDQMfiles,")")
0071 return -1
0072
0073
0074 listOfInputTags.sort()
0075 TARGET_LIST_OF_TAGS.sort()
0076
0077
0078 if(listOfInputTags!=TARGET_LIST_OF_TAGS):
0079 print(" list of input tags found in file:",listOfInputTags)
0080 print(" target list of tags:",TARGET_LIST_OF_TAGS)
0081
0082 if (listOfInputTags>TARGET_LIST_OF_TAGS):
0083 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!")
0084 else:
0085 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!")
0086 return -1
0087
0088 return 0
0089
0090
0091 def main():
0092 try:
0093 f = open(TARGET_XML_FILENAME)
0094 except IOError:
0095 print("%s is not accessible" % TARGET_XML_FILENAME)
0096 sys.exit(1)
0097
0098
0099 result = parseXML(TARGET_XML_FILENAME)
0100 if(result==0):
0101 print("All is fine with the world!")
0102 sys.exit(0)
0103 else:
0104 print("Parsing the FwkJobReport results in failure!")
0105 sys.exit(1)
0106
0107
0108 if __name__ == "__main__":
0109
0110
0111 main()