예제 #1
0
파일: cmdline.py 프로젝트: hsatoshi/pxar
    def plot_2d(self,data,name,dac1,step1,min1,max1,dac2,step2,min2,max2):
        if(not self.window):
            for idac, dac in enumerate(data):
                dac1 = min1 + (idac/((max2-min2)/step2+1))*step1
                dac2 = min2 + (idac%((max2-min2)/step2+1))*step2
                s = "DACs " + str(dac1) + ":" + str(dac2) + " - "
                for px in dac:
                    s += str(px)
                print s
            return
        
        # Prepare new numpy matrix:
        bins1 = (max1-min1)/step1+1
        bins2 = (max2-min2)/step2+1
        d = zeros((bins1,bins2))

        for idac, dac in enumerate(data):
            if(dac):
                bin1 = (idac/((max2-min2)/step2+1))
                bin2 = (idac%((max2-min2)/step2+1))
                d[bin1][bin2] = dac[0].value

        plot = Plotter.create_th2(d, min1, max1, min2, max2, name, dac1, dac2, name)
        self.window.histos.append(plot)
        self.window.update()
예제 #2
0
파일: cmdline.py 프로젝트: hsatoshi/pxar
    def plot_map(self,data,name,count=False):
        if(not self.window):
            print data
            return

        # Find number of ROCs present:
        module = False
        for px in data:
            if px.roc > 0:
                module = True
                break

        # Prepare new numpy matrix:
        d = zeros((416 if module else 52,160 if module else 80))

        for px in data:
            xoffset = 52*(px.roc%8) if module else 0
            yoffset = 80*int(px.roc/8) if module else 0
            # Flip the ROCs upside down:
            y = (px.row + yoffset) if (px.roc < 8) else (2*yoffset - px.row - 1)
            # Reverse order of the upper ROC row:
            x = (px.column + xoffset) if (px.roc < 8) else (415 - xoffset - px.column)
            d[x][y] += 1 if count else px.value

        plot = Plotter.create_th2(d, 0, 415 if module else 51, 0, 159 if module else 79, name, 'pixels x', 'pixels y', name)
        self.window.histos.append(plot)
        self.window.update()
예제 #3
0
    def do_analogLevelScan(self):
        """analogLevelScan: scan the ADC levels of an analog ROC"""
        self.api.daqStart()
        self.api.daqTrigger(5000,500)
        plotdata = zeros(1024)

        try:
            while True:
                s = ""
                p = ""
                pos = -3
                dat = self.api.daqGetRawEvent()
                for i in dat:
                    i = i & 0x0fff
                    # Remove PH from hits:
                    if pos == 5:
                        pos = 0
                        continue
                    if i & 0x0800:
                        i -= 4096
                    plotdata[500+i] += 1
                    pos += 1
        except RuntimeError:
            pass

        plot = Plotter.create_th1(plotdata, -512, +512, "Address Levels", "ADC", "#")
        self.window.histos.append(plot)
        self.window.update()
예제 #4
0
    def do_analogLevelScan(self):
        """analogLevelScan: scan the ADC levels of an analog ROC"""
        self.api.daqStart()
        self.api.daqTrigger(5000, 500)
        plotdata = zeros(1024)

        try:
            while True:
                s = ""
                p = ""
                pos = -3
                dat = self.api.daqGetRawEvent()
                for i in dat:
                    i = i & 0x0fff
                    # Remove PH from hits:
                    if pos == 5:
                        pos = 0
                        continue
                    if i & 0x0800:
                        i -= 4096
                    plotdata[500 + i] += 1
                    pos += 1
        except RuntimeError:
            pass

        plot = Plotter.create_th1(plotdata, -512, +512, "Address Levels",
                                  "ADC", "#")
        self.window.histos.append(plot)
        self.window.update()
예제 #5
0
    def plot_map(self, data, name, count=False):
        if (not self.window):
            print data
            return

        # Find number of ROCs present:
        module = False
        for px in data:
            if px.roc > 0:
                module = True
                break

        # Prepare new numpy matrix:
        d = zeros((416 if module else 52, 160 if module else 80))

        for px in data:
            xoffset = 52 * (px.roc % 8) if module else 0
            yoffset = 80 * int(px.roc / 8) if module else 0
            # Flip the ROCs upside down:
            y = (px.row + yoffset) if (px.roc < 8) else (2 * yoffset - px.row -
                                                         1)
            # Reverse order of the upper ROC row:
            x = (px.column + xoffset) if (px.roc < 8) else (415 - xoffset -
                                                            px.column)
            d[x][y] += 1 if count else px.value

        plot = Plotter.create_th2(d, 0, 415 if module else 51, 0,
                                  159 if module else 79, name, 'pixels x',
                                  'pixels y', name)
        self.window.histos.append(plot)
        self.window.update()
예제 #6
0
    def plot_2d(self, data, name, dac1, step1, min1, max1, dac2, step2, min2,
                max2):
        if (not self.window):
            for idac, dac in enumerate(data):
                dac1 = min1 + (idac / ((max2 - min2) / step2 + 1)) * step1
                dac2 = min2 + (idac % ((max2 - min2) / step2 + 1)) * step2
                s = "DACs " + str(dac1) + ":" + str(dac2) + " - "
                for px in dac:
                    s += str(px)
                print s
            return

        # Prepare new numpy matrix:
        bins1 = (max1 - min1) / step1 + 1
        bins2 = (max2 - min2) / step2 + 1
        d = zeros((bins1, bins2))

        for idac, dac in enumerate(data):
            if (dac):
                bin1 = (idac / ((max2 - min2) / step2 + 1))
                bin2 = (idac % ((max2 - min2) / step2 + 1))
                d[bin1][bin2] = dac[0].value

        plot = Plotter.create_th2(d, min1, max1, min2, max2, name, dac1, dac2,
                                  name)
        self.window.histos.append(plot)
        self.window.update()
예제 #7
0
파일: cmdline.py 프로젝트: hsatoshi/pxar
    def plot_1d(self,data,name,dacname,min,max):
        if(not self.window):
            print_data(self.fullOutput,data,(max-min)/len(data))
            return

        # Prepare new numpy matrix:
        d = zeros(len(data))
        for idac, dac in enumerate(data):
            if(dac):
                d[idac] = dac[0].value

        plot = Plotter.create_th1(d, min, max, name, dacname, name)
        self.window.histos.append(plot)
        self.window.update()
예제 #8
0
    def plot_1d(self, data, name, dacname, min, max):
        if (not self.window):
            print_data(self.fullOutput, data, (max - min) / len(data))
            return

        # Prepare new numpy matrix:
        d = zeros(len(data))
        for idac, dac in enumerate(data):
            if (dac):
                d[idac] = dac[0].value

        plot = Plotter.create_th1(d, min, max, name, dacname, name)
        self.window.histos.append(plot)
        self.window.update()
예제 #9
0
    def do_latencyScan(self,
                       minlatency=50,
                       maxlatency=100,
                       triggers=10,
                       triggersignal="extern"):
        """ do_latencyScan [min] [max] [triggers] [signal]: scan the trigger latency from min to max with set number of triggers)"""

        self.api.testAllPixels(0, None)
        self.api.HVon()

        latencyScan = []
        print "latency \tyield"

        # loop over latency
        for latency in range(minlatency, maxlatency):
            delay = {}
            delay["triggerlatency"] = latency
            self.api.setTestboardDelays(delay)
            self.api.daqTriggerSource(triggersignal)
            self.api.daqStart()
            nHits = 0
            nTriggers = 0

            #loop until you find maxTriggers
            while nTriggers < triggers:
                try:
                    data = self.api.daqGetEvent()
                    if len(data.pixels) > 0:
                        nHits += 1
                    nTriggers += 1
                except RuntimeError:
                    pass

            hitYield = 100 * nHits / triggers
            latencyScan.append(hitYield)
            print '{0:03d}'.format(latency), "\t", '{0:3.0f}%'.format(hitYield)
            self.api.daqStop()

        if (self.window):
            self.window = PxarGui(ROOT.gClient.GetRoot(), 1000, 800)
            plot = Plotter.create_tgraph(latencyScan, "latency scan",
                                         "trigger latency", "evt/trig [%]",
                                         minlatency)
            self.window.histos.append(plot)
            self.window.update()
예제 #10
0
    def do_wbcScan(self,
                   minWBC=90,
                   maxWBC=255,
                   maxTriggers=10,
                   triggersignal="extern"):
        """ do_wbcScan [minWBC] [maxWBC] [maxTriggers] [signal]: sets the values of wbc from minWBC until it finds the wbc which has more than 90% filled events or it reaches 255 (default minWBC 90)"""

        self.api.daqTriggerSource(triggersignal)
        self.api.HVon()

        wbcScan = []
        print "wbc \tyield"

        # loop over wbc
        for wbc in range(minWBC, maxWBC):
            self.api.setDAC("wbc", wbc)
            self.api.daqStart()
            nHits = 0
            nTriggers = 0

            #loop until you find maxTriggers
            while nTriggers < maxTriggers:
                try:
                    data = self.api.daqGetEvent()
                    if len(data.pixels) > 0:
                        nHits += 1
                    nTriggers += 1
                except RuntimeError:
                    pass

            hitYield = 100 * nHits / maxTriggers
            wbcScan.append(hitYield)
            print '{0:03d}'.format(wbc), "\t", '{0:3.0f}%'.format(hitYield)

            self.api.daqStop()

        if (self.window):
            self.window = PxarGui(ROOT.gClient.GetRoot(), 1000, 800)
            plot = Plotter.create_tgraph(wbcScan, "wbc scan", "wbc",
                                         "evt/trig [%]", minWBC)
            self.window.histos.append(plot)
            self.window.update()
예제 #11
0
    def do_latencyScan(self, minlatency = 50, maxlatency = 100, triggers = 10, triggersignal = "extern"):
        """ do_latencyScan [min] [max] [triggers] [signal]: scan the trigger latency from min to max with set number of triggers)"""

        self.api.testAllPixels(0,None)
        self.api.HVon();

        latencyScan = []
        print "latency \tyield"

        # loop over latency
        for latency in range (minlatency,maxlatency):
            delay = {}
            delay["triggerlatency"] = latency
            self.api.setTestboardDelays(delay)
            self.api.daqTriggerSource(triggersignal)
            self.api.daqStart()
            nHits       = 0
            nTriggers   = 0

            #loop until you find maxTriggers
            while nTriggers < triggers:
                try:
                    data = self.api.daqGetEvent()
                    if len(data.pixels) > 0:
                       nHits += 1
                    nTriggers += 1
                except RuntimeError:
                    pass

            hitYield = 100*nHits/triggers
            latencyScan.append(hitYield)
            print '{0:03d}'.format(latency),"\t", '{0:3.0f}%'.format(hitYield)
            self.api.daqStop()

        if(self.window):
            self.window = PxarGui( ROOT.gClient.GetRoot(), 1000, 800 )
            plot = Plotter.create_tgraph(latencyScan, "latency scan", "trigger latency", "evt/trig [%]", minlatency)
            self.window.histos.append(plot)
            self.window.update()
예제 #12
0
    def do_wbcScan(self, minWBC = 90, maxWBC = 255, maxTriggers = 10, triggersignal = "extern"):
        """ do_wbcScan [minWBC] [maxWBC] [maxTriggers] [signal]: sets the values of wbc from minWBC until it finds the wbc which has more than 90% filled events or it reaches 255 (default minWBC 90)"""

        self.api.daqTriggerSource(triggersignal)
        self.api.HVon();

        wbcScan = []
        print "wbc \tyield"

        # loop over wbc
        for wbc in range (minWBC,maxWBC):
            self.api.setDAC("wbc", wbc)
            self.api.daqStart()
            nHits       = 0
            nTriggers   = 0

            #loop until you find maxTriggers
            while nTriggers < maxTriggers:
                try:
                    data = self.api.daqGetEvent()
                    if len(data.pixels) > 0:
                       nHits += 1
                    nTriggers += 1
                except RuntimeError:
                    pass

            hitYield = 100*nHits/maxTriggers
            wbcScan.append(hitYield)
            print '{0:03d}'.format(wbc),"\t", '{0:3.0f}%'.format(hitYield)

            self.api.daqStop()

        if(self.window):
            self.window = PxarGui( ROOT.gClient.GetRoot(), 1000, 800 )
            plot = Plotter.create_tgraph(wbcScan, "wbc scan", "wbc", "evt/trig [%]", minWBC)
            self.window.histos.append(plot)
            self.window.update()