Ejemplo n.º 1
0
class TestResult(AbstractClasses.GeneralTestResult.GeneralTestResult):
    def CustomInit(self):
        self.NameSingle = 'ThresholdOverview'
        self.Name = 'CMSPixel_QualificationGroup_XRayHRQualification_%s_TestResult' % self.NameSingle
        self.Attributes['TestedObjectType'] = 'CMSPixel_Module'

    def PopulateResultData(self):
        ROOT.gPad.SetLogy(0)
        ROOT.gStyle.SetOptStat(0)

        # initialize module map
        self.ModuleMap = ModuleMap(
            Name=self.GetUniqueID(),
            nChips=self.ParentObject.Attributes['NumberOfChips'],
            StartChip=self.ParentObject.Attributes['StartChip'])
        Directory = self.ParentObject.Attributes['SCurvePaths'][
            'HRSCurves_{Rate}'.format(Rate=self.Attributes['Rate'])]

        for i in self.ParentObject.ResultData['SubTestResults'][
                'Chips'].ResultData['SubTestResults']:
            ChipTestResultObject = self.ParentObject.ResultData[
                'SubTestResults']['Chips'].ResultData['SubTestResults'][i]
            ChipNo = ChipTestResultObject.Attributes['ChipNo']

            SCurveFileName = Directory + '/' + self.ParentObject.ParentObject.HistoDict.get(
                'HighRate', 'SCurveFileName').format(ChipNo=ChipNo)
            SCurveFile = open(SCurveFileName, "r")

            if not SCurveFile:
                raise Exception('Cannot find SCurveFile "%s"' % SCurveFileName)
            else:
                Line = SCurveFile.readline()
                Line = SCurveFile.readline()

                for column in range(self.nCols):  #Columns
                    for row in range(self.nRows):  #Rows
                        Line = SCurveFile.readline()
                        if Line:
                            LineArray = Line.strip().split()
                            Threshold = float(LineArray[0])
                            if 0 < Threshold < 10000:
                                self.ModuleMap.UpdatePlot(
                                    ChipNo, column, row, Threshold)
            SCurveFile.close()

        # draw module map
        if self.ModuleMap:
            self.ModuleMap.SetContour(100)
            self.ResultData['Plot'][
                'ROOTObject'] = self.ModuleMap.GetHistogram()
            if self.isPROC:
                self.ModuleMap.SetRangeUser(1200, 5000)
            else:
                self.ModuleMap.SetRangeUser(1200, 2800)
            self.ModuleMap.Draw(Canvas=self.Canvas, TitleZ="electrons")

        # save canvas
        self.ResultData['Plot']['Format'] = 'png'
        self.Title = 'Threshold {Rate}'.format(Rate=self.Attributes['Rate'])
        self.SaveCanvas()
Ejemplo n.º 2
0
class TestResult(AbstractClasses.GeneralTestResult.GeneralTestResult):
    def CustomInit(self):
        self.Name='CMSPixel_QualificationGroup_XRayHRQualification_HitOverview_TestResult'
        self.NameSingle='HitOverview'
        self.Attributes['TestedObjectType'] = 'CMSPixel_Module'

    def PopulateResultData(self):
        ROOT.gStyle.SetOptStat(0)
        self.Canvas.Clear()

        # initialize module map
        self.ModuleMap = ModuleMap(Name=self.GetUniqueID(), nChips=self.ParentObject.Attributes['NumberOfChips'], StartChip=self.ParentObject.Attributes['StartChip'])

        try:
            Rate = self.Attributes['Rate']
        except:
            Rate = ''

        # copy ROC data to module data
        for i in self.ParentObject.ResultData['SubTestResults']['Chips'].ResultData['SubTestResults']:
            ChipTestResultObject = self.ParentObject.ResultData['SubTestResults']['Chips'].ResultData['SubTestResults'][i]
            histo = ChipTestResultObject.ResultData['SubTestResults']['HitMap_{Rate}'.format(Rate=Rate) if Rate else 'HitMap'].ResultData['Plot']['ROOTObject']
            chipNo = ChipTestResultObject.Attributes['ChipNo']

            for col in range(self.nCols): 
                for row in range(self.nRows):
                    result = histo.GetBinContent(col + 1, row + 1)
                    self.ModuleMap.UpdatePlot(chipNo, col, row, result)

        # draw module map
        if self.ModuleMap:
            self.ResultData['Plot']['ROOTObject'] = self.ModuleMap.GetHistogram()
            self.ModuleMap.SetContour(100)

            self.ResultData['Plot']['ROOTObject'].GetZaxis().SetRangeUser(0, self.ResultData['Plot']['ROOTObject'].GetMaximum())

            try:
                XProjection = self.ResultData['Plot']['ROOTObject'].ProjectionX('hproj_{Rate}_{id}'.format(Rate=Rate, id=self.GetUniqueID()), 50, 50)
                XProjectionList = []
                for col in range(XProjection.GetXaxis().GetFirst(), XProjection.GetXaxis().GetLast()+1):
                    XProjectionList.append(XProjection.GetBinContent(col))
                XProjectionList.sort()
                Median = XProjectionList[int(len(XProjectionList)/2)]

                if self.ResultData['Plot']['ROOTObject'].GetMaximum() > Median*3:
                    self.ResultData['Plot']['ROOTObject'].GetZaxis().SetRangeUser(0, Median*3)
            except:
                pass

            self.ModuleMap.Draw(Canvas=self.Canvas, TitleZ="# hits")

        # save canvas
        self.ResultData['Plot']['Format'] = 'png'
        self.Title = 'Hit Map {Rate}'.format(Rate=Rate)
        self.SaveCanvas()
Ejemplo n.º 3
0
class TestResult(AbstractClasses.GeneralTestResult.GeneralTestResult):
    def CustomInit(self):
        self.Name='CMSPixel_QualificationGroup_XrayCalibrationSpectrum_HitmapOverview_TestResult'
        self.NameSingle='HitmapOverview'
        self.Attributes['TestedObjectType'] = 'CMSPixel_Module'

    def PopulateResultData(self):
        ROOT.gPad.SetLogy(0)
        ROOT.gStyle.SetOptStat(0)

        # initialize module map
        self.ModuleMap = ModuleMap(Name=self.GetUniqueID(), nChips=self.ParentObject.Attributes['NumberOfChips'], StartChip=self.ParentObject.Attributes['StartChip'])

        for i in self.ParentObject.ResultData['SubTestResults']['Chips_Xray'].ResultData['SubTestResults']:
            ChipTestResultObject = self.ParentObject.ResultData['SubTestResults']['Chips_Xray'].ResultData['SubTestResults'][i]
            chipNo = ChipTestResultObject.Attributes['ChipNo']
            SubTestKey = 'Xray_HitMap_{Method}_{Target}_Chip{Chip}'.format(Method=self.Attributes['Method'], Target=self.Attributes['Target'], Chip=chipNo)
            histo = ChipTestResultObject.ResultData['SubTestResults'][SubTestKey].ResultData['Plot']['ROOTObject']

            for col in range(self.nCols):
                for row in range(self.nRows):
                    result = histo.GetBinContent(col + 1, row + 1)
                    self.ModuleMap .UpdatePlot(chipNo, col, row, result)

        # draw module map
        if self.ModuleMap:
            self.ResultData['Plot']['ROOTObject'] = self.ModuleMap.GetHistogram()
            self.ModuleMap.SetContour(100)

            self.ResultData['Plot']['ROOTObject'].GetZaxis().SetRangeUser(0, self.ResultData['Plot']['ROOTObject'].GetMaximum())

            try:
                XProjection = self.ResultData['Plot']['ROOTObject'].ProjectionX('hproj_{Target}_{id}'.format(Target=self.Attributes['Target'], id=self.GetUniqueID()), 50, 50)
                XProjectionList = []
                for col in range(XProjection.GetXaxis().GetFirst(), XProjection.GetXaxis().GetLast()+1):
                    XProjectionList.append(XProjection.GetBinContent(col))
                XProjectionList.sort()
                Median = XProjectionList[int(len(XProjectionList)/2)]

                if self.ResultData['Plot']['ROOTObject'].GetMaximum() > Median*3:
                    self.ResultData['Plot']['ROOTObject'].GetZaxis().SetRangeUser(0, Median*3)
            except:
                pass

            self.ModuleMap.Draw(Canvas=self.Canvas, TitleZ="# hits")

        # save canvas
        self.ResultData['Plot']['Format'] = 'png'
        self.Title = 'Hit Map {Target}'.format(Target=self.Attributes['Target'])
        self.SaveCanvas()

    def UpdatePlot(self, chipNo, col, row, value):
        result = value
        if chipNo < 8:
            tmpCol = 8 * self.nCols - 1 - chipNo * self.nCols - col
            tmpRow = 2 * self.nRows - 1 - row
        else:
            tmpCol = (chipNo % 8 * self.nCols + col)
            tmpRow = row
        # Get the data from the chip sub test result hitmap

        if result and self.verbose:
            print chipNo, col, row, '--->', tmpCol, tmpRow, result
        self.ResultData['Plot']['ROOTObject'].Fill(tmpCol, tmpRow, result)
Ejemplo n.º 4
0
class ProductionOverview(
        AbstractClasses.GeneralProductionOverview.GeneralProductionOverview):
    def CustomInit(self):
        self.Name = 'CMSPixel_ProductionOverview_XrayMap'
        self.NameSingle = 'XrayMap'

        self.DisplayOptions = {
            'Width': 2.7 * 2,
        }
        self.SubPages = []
        self.SavePlotFile = True
        self.Canvas.SetCanvasSize(1330, 430)
        self.Canvas.Update()

    def GenerateOverview(self):
        Rows = self.FetchData()
        ModuleIDsList = self.GetModuleIDsList(Rows)
        ROOT.gStyle.SetOptStat(0)

        # initialize module map
        self.ModuleMap = ModuleMap(Name=self.GetUniqueID(),
                                   nChips=16,
                                   StartChip=0)
        self.ModuleMap.SetContour(100)

        NModules = 0
        TotalMaximum = 0
        for RowTuple in Rows:
            if RowTuple['ModuleID'] in ModuleIDsList:
                ModuleID = RowTuple['ModuleID']

                TestType = 'XrayCalibration_Spectrum'
                if RowTuple['TestType'].startswith(TestType):

                    Path = '/'.join([
                        self.GlobalOverviewPath,
                        RowTuple['RelativeModuleFinalResultsPath'],
                        RowTuple['FulltestSubfolder'],
                        "HitmapOverview_" + self.Attributes["Target"], '*.root'
                    ])
                    print Path
                    RootFiles = glob.glob(Path)
                    ROOTObject = self.GetHistFromROOTFile(RootFiles, "Map")

                    if ROOTObject:
                        self.ModuleMap.AddTH2D(ROOTObject=ROOTObject)
                        TotalMaximum += ROOTObject.GetMaximum()
                        NModules += 1
                    else:
                        self.ProblematicModulesList.append(ModuleID)
                        print "warning: xray map not found for module: '%s'" % ModuleID
                else:
                    print RowTuple['TestType']
        self.ModuleMap.Map2D.GetZaxis().SetRangeUser(0, TotalMaximum)

        # draw module map
        if self.ModuleMap:
            self.ModuleMap.Draw(self.Canvas)

        title = ROOT.TText()
        title.SetNDC()
        title.SetTextAlign(12)
        Subtitle = self.Attributes["Target"] + " modules: %d" % NModules
        title.DrawText(0.15, 0.965, Subtitle)

        self.SaveCanvas('png')
        HTML = self.Image(self.Attributes['ImageFile'])

        AbstractClasses.GeneralProductionOverview.GeneralProductionOverview.GenerateOverview(
            self)

        self.DisplayErrorsList()
        return self.Boxed(HTML)