Skip to content
Snippets Groups Projects
Commit 469003ff authored by Ya Zhao's avatar Ya Zhao
Browse files

add python script used to compare two ReadoutMaps

parent 67be7b1d
No related branches found
No related tags found
1 merge request!414add python script used to compare two ReadoutMaps
Pipeline #5845378 failed with stages
in 6 minutes and 23 seconds
###############################################################################
# (c) Copyright 2020 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# This script is used to compare two ReadoutMaps and print the difference
# usage:
# python compareTwoMaps.py <first map xml file> <second map xml file>
# example:
# python compareTwoMaps.py ReadoutMap_SFCAVERN_SF_20220922_142756_All-FixedOrder.xml outputFiles/SFCAVERN_SF_20230418/ReadoutMap.xml
import os
import sys
import xml.etree.ElementTree as ET
def get_SourceIDs_ChannelIDs(xmlfilename):
tree = ET.parse(xmlfilename)
root = tree.getroot()
for child in root:
if(child.tag == "condition"):
for subchild in child:
if( (subchild.tag == "paramVector") and (subchild.attrib["name"]=="sourceIDs") ):
text_SourceIDs = subchild.text
list_SourceIDs = text_SourceIDs.split()
if( (subchild.tag == "paramVector") and (subchild.attrib["name"]=="LinkMap") ):
text_ChannelIDs = subchild.text
list_ChannelIDs = text_ChannelIDs.split()
return list_SourceIDs, list_ChannelIDs
if (len(sys.argv) != 3):
print("ERROR: please check number of arguments.")
exit()
filename1 = sys.argv[1]
filename2 = sys.argv[2]
list_SourceIDs_1, list_ChannelIDs_1 = get_SourceIDs_ChannelIDs(filename1)
list_SourceIDs_2, list_ChannelIDs_2 = get_SourceIDs_ChannelIDs(filename2)
print("print some values...\n")
print(list_SourceIDs_1, " lenth = ", len(list_SourceIDs_1))
print(list_SourceIDs_2, " lenth = ", len(list_SourceIDs_2))
print("list_ChannelIDs_1: ", list_ChannelIDs_1[0:10], " ", list_ChannelIDs_1[-10:], " lenth = ", len(list_ChannelIDs_1))
print("list_ChannelIDs_2: ", list_ChannelIDs_2[0:10], " ", list_ChannelIDs_2[-10:], " lenth = ", len(list_ChannelIDs_2))
if( len(list_SourceIDs_1) != len(list_SourceIDs_2) ):
print("ERROR: the number of SourceIDs in first map is " + str(len(list_SourceIDs_1)) + ", in second map is " + str(len(list_SourceIDs_2)))
exit()
if( len(list_ChannelIDs_1) != len(list_ChannelIDs_2) ):
print("ERROR: the number of ChannelIDs in first map is " + str(len(list_ChannelIDs_1)) + ", in second map is " + str(len(list_ChannelIDs_2)))
exit()
count = 0
print("comparing SourceIDs...")
for i in range(len(list_SourceIDs_1)):
if( list_SourceIDs_1[i] != list_SourceIDs_2[i] ):
count+=1
print("FOUND difference: index = "+str(i)+", value in first map = "+list_SourceIDs_1[i]+", value in second map = "+list_SourceIDs_2[i])
if count == 0:
print("no difference found")
count = 0
print("comparing ChannelIDs...")
for i in range(len(list_ChannelIDs_1)):
if( list_ChannelIDs_1[i] != list_ChannelIDs_2[i] ):
count+=1
print("FOUND difference: index = "+str(i)+"(row="+str(i//24)+", column="+str(i%24)+"), value in first map = "+list_ChannelIDs_1[i]+", value in second map = "+list_ChannelIDs_2[i])
if count == 0:
print("no difference found")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment