def ExecuteCut(self, matrix, axis): if self.regionMarkers.IsPending() or len(self.regionMarkers) == 0: return None self.matrix = matrix self.axis = axis spec = self.matrix.ExecuteCut(self) self.spec = weakref(spec) return spec
def _set_spec(self, spec): if hasattr(self, "spec") and self._spec == spec: return # use weakref to prevent problems with cyclic reference self._spec = weakref(spec) self.Erase() if spec is None: self.FixMarkerInCal() self.cal = None self.color = None else: self.color = spec.color self.cal = spec.cal self.FixMarkerInUncal()
def Restore(self, spec): # do not call Erase() while setting spec! self._spec = weakref(spec) self.cal = spec.cal self.color = spec.color self.FixMarkerInUncal() if len(self.bgMarkers) > 0 and not self.bgMarkers.IsPending(): backgrounds = Pairs() for m in self.bgMarkers: backgrounds.add(m.p1.pos_uncal, m.p2.pos_uncal) self.fitter.RestoreBackground(backgrounds=backgrounds, params=self.bgParams, chisquare=self.bgChi) region = sorted([ self.regionMarkers[0].p1.pos_uncal, self.regionMarkers[0].p2.pos_uncal ]) print(self.bgParams) if self.peaks: self.fitter.RestorePeaks( cal=self.cal, region=region, peaks=self.peaks, chisquare=self.chi, coeffs=self.bgParams, ) # get background function func = self.fitter.peakFitter.GetBgFunc() self.dispBgFunc = ROOT.HDTV.Display.DisplayFunc(func, self.color) self.dispBgFunc.SetCal(self.cal) # get peak function func = self.fitter.peakFitter.GetSumFunc() self.dispPeakFunc = ROOT.HDTV.Display.DisplayFunc(func, self.color) self.dispPeakFunc.SetCal(self.cal) # restore display functions of single peaks for i in range(0, self.fitter.peakFitter.GetNumPeaks()): cpeak = self.fitter.peakFitter.GetPeak(i) func = cpeak.GetPeakFunc() self.peaks[i].displayObj = ROOT.HDTV.Display.DisplayFunc( func, self.color) self.peaks[i].displayObj.SetCal(self.cal) # create non-existant integral if not self.integral: self.integral = hdtv.integral.Integrate( self.spec, self.fitter.bgFitter, region)
def project(self, axis): """ Return Projection along a given axis """ if getattr(self, "_%sproj" % axis) is None: # no valid link to that projection, create fresh object hist = getattr(self.histo2D, "%sproj" % axis) if self.sym: a = "0" else: a = axis proj = CutSpectrum(hist, self, axis=a) proj.color = self.color setattr(self, "_%sproj" % axis, weakref(proj)) return proj else: return getattr(self, "_%sproj" % axis)