Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#!/usr/bin/env python

'''
This script checks the outputs from SiStripDetVOffFakeBuilder and reader. It compares the status of all detIds
both for low and high voltage and it checks that the values written in the database are correctly read back.
'''

import os

def getDetIds(fileName, vType):
    return os.popen("cat "+fileName+" | grep \"detid\" | grep \""+vType+"\" | grep \"OFF\" | awk \'{print $2}\' ", "r")


def compare(vType):
    #builderChild = os.popen("cat SiStripDetVOffFakeBuilder.log | grep \"detid\" | grep \"HV\" | awk \'{print $2}\' ", "r")
    builderChild = getDetIds("SiStripDetVOffFakeBuilder.log", vType)
    builderOutput = builderChild.read()

    #readerChild = os.popen("cat SiStripDetVOffReader.log | grep \"detid\" | grep \"HV\" | grep \"OFF\" | awk \'{print $2}\' ", "r")
    readerChild = getDetIds("SiStripDetVOffReader.log", vType)
    readerOutput = readerChild.read()

    builderDetIds = builderOutput.split('\n')
    readerDetIds = readerOutput.split('\n')

    builderDetIds = sorted(builderDetIds)

    #builderLine = popen

    i = 0
    printNum = 5
    print("Checking", vType, ":")
    print("printing the first ", printNum, " for comparison")
    for detId in builderDetIds:
        #if( i < 1000 ):
        # print "detId = ", detId
        builderDetId = detId
        #print "DetId = ", builderDetIds[i].split()
        readerDetId = readerDetIds[i]
        # print "builderDetId = ", readerDetId
        if( builderDetId ):
            readerDetId = readerDetIds[i]
            # builderDetId = builderDetIds[i].split()[0]           
            if( readerDetId != builderDetId ):
                print("does not match: builder = ", detId, " reader = ", readerDetIds[i])
            if( i < printNum ):
                print("builder = ", detId)
                print("reader = ", readerDetIds[i])
            i += 1
    print()


builderFile = open("SiStripDetVOffFakeBuilder.log")
readerFile = open("SiStripDetVOffReader.log")

compare("HV")
compare("LV")
compare(" V")