def DrawMergedTriggerEfficiency(inputfile, datatype="tracks", sourcetype="tracksWithClusters"): reader = ResultDataBuilder("resultfile", inputfile) data = reader.GetResults() plotter = TriggerEfficiencyPlotClasses() styles = { "EMCJHigh": Style(kBlue, 24), "EMCJLow": Style(kRed, 25), "EMCGHigh": Style(kGreen, 26), "EMCGLow": Style(kOrange, 27) } for trigger in ["EMCJHigh", "EMCJLow", "EMCGHigh", "EMCGLow"]: dataminbias = None datatriggered = None if datatype == "clusters": dataminbias = data.GetData("MinBias").FindClusterContainer( sourcetype) datatriggered = data.GetData(trigger).FindClusterContainer( sourcetype) elif datatype == "tracks": dataminbias = data.GetData("MinBias").FindTrackContainer( sourcetype) datatriggered = data.GetData(trigger).FindTrackContainer( sourcetype) plotter.AddTriggerEfficiency( trigger, TriggerEfficiency(trigger, dataminbias, datatriggered).GetEfficiencyCurve(), styles[trigger]) plotter.Create() return plotter
def DrawPtReach(filename, doIntegral=False): reader = LegoTrainFileReader(filename) content = reader.ReadFile() content.SetName("RawSpectra") plot = PtReachPlot() triggers = ["MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh", "EMCGLow"] styles = { "MinBias": Style(kBlack, 20), "EMCJHigh": Style(kRed, 24), "EMCJLow": Style(kOrange, 25), "EMCGHigh": Style(kBlue, 26), "EMCGLow": Style(kGreen, 27) } isMinBias = False for trigger in triggers: if trigger == "MinBias": isMinBias = True else: isMinBias = False plot.AddData( trigger, PtReachData(trigger, MakeNormalisedSpectrum(content.GetData(trigger)), isMinBias, doIntegral), styles[trigger]) plot.Create() return plot
def __init__(self, data, fitmin): self.__data = data self.__mbfitter = MinBiasFitter(data, fitmin) self.__parameterised = self.__CreateBinnedParameterisation() self.__ratio = self.__CreateRatioDataParam() self.__xrange = {"min":None, "max":None} self.__graphs = {"Data" : None, "Param" : None, "Ratio" : None } self.__styles = {"Data" : Style(kRed, 24), "Param" : Style(kBlue, 25), "Ratio" : Style(kBlack, 20) }
def DrawPeriodComparison(reference, periods, trigger): styles = [Style(kRed, 24), Style(kBlue, 25), Style(kGreen, 26), Style(kMagenta, 27), Style(kOrange, 28), Style(kYellow, 29), Style(kTeal, 30)] plot = RawspectrumPeriodComparisonPlot() plot.AddRawSpectrum(reference["period"], GetRawSpectrum(reference["file"], trigger), Style(kBlack, 20), True) counter = 0 for period in periods: plot.AddRawSpectrum(period["period"], GetRawSpectrum(period["file"], trigger), styles[counter], False) counter += 1 plot.AddLabel("Trigger: %s" %(trigger)) plot.Create() return plot
def CreateTurnonPlot(filename, filenameMB, fitminval = 15., requireCluster = False): trackHistName = "tracksAll" if requireCluster: trackHistName = "tracksWithClusters" data = ReadData(filename) dataMB = ReadData(filenameMB) styles = {"EMCJHigh" : Style(kRed, 24), "EMCJLow" : Style(kOrange, 26), "EMCGHigh" : Style(kBlue, 25), "EMCGLow" : Style(kGreen, 27)} plot = TriggerTurnonPlot() minbiasspectrum = MakeNormalisedSpectrum(dataMB.GetData("MinBias").FindTrackContainer(trackHistName),"MinBias") for trg in styles.keys(): plot.AddData(trg, TriggerTurnonCurve(trg, MakeNormalisedSpectrum(data.GetData(trg).FindTrackContainer(trackHistName), trg), minbiasspectrum, fitminval), styles[trg]) plot.Create() return plot
def CheckFitRanges(filename): reader = LegoTrainFileReader(filename) mbspectrum = MakeNormalisedSpectrum(reader.ReadFile().GetData("MinBias").FindTrackContainer("tracksAll"), "MinBias") plot = MultipleFitPlot() styles = {10:Style(kBlue,24),15:Style(kBlack,25),20:Style(kRed,26),25:Style(kGreen,27)} for imin in range(10, 30, 5): comparison = DataFitComparison(mbspectrum, imin) comparison.SetRange(2., 100.) comparison.SetStyle("Param",styles[imin]) isRef = False if imin == 15: isRef = True plot.SetData(comparison,imin,isRef) plot.Create() return plot
def CreatePlot(self): self._datacol = self.__handler.GetCollection() styles = [Style(kGreen-2, 24), Style(kBlue, 25), Style(kRed, 26), Style(kGreen, 27), Style(kMagenta, 28), Style(kOrange, 29), \ Style(kTeal, 30), Style(kViolet, 31), Style(kGray, 32), Style(kYellow + 2, 33), Style(kCyan+3, 34), Style(kRed-9, 35)] for i in range(1, self.__nbins + 1): spectrum = self._SpectrumForPtHatBin(i) self._datacol.GetWeigthHandler().ReweightSpectrum(i, spectrum) self.__plotter.AddMCSpectrum(i, spectrum, styles[i]) self.__plotter.Create() return self.__plotter
def DrawObjects(self, pad, addtolegend=True): """ Draw all spectra inside the container into a given pad """ ComparisonData.DrawObjects(self, pad, addtolegend) # draw also sum of the different bins pad.DrawGraphicsObject( GraphicsObject(self.GetSpectraSum(), Style(kBlack, 20)), addtolegend, "Sum")
def GetGraphicsInRange(self, trigger, isRatio=False): graphics = None styles = { "MinBias": Style(kBlack, 20), "EMCJHigh": Style(kBlue, 24), "EMCJLow": Style(kRed, 26), "EMCGHigh": Style(kGreen, 25), "EMCGLow": Style(kOrange, 27) } if trigger is "MinBias": graphics = GraphicsObject(HistToGraph(self.__minBias, 0.1, 100.), styles["MinBias"]) else: mydict = self.__triggered if isRatio: mydict = self.__ratios graphics = GraphicsObject(HistToGraph(mydict[trigger], 0.1, 100.), styles[trigger]) return graphics
def Create(self): """ Create the plot """ self._OpenCanvas("trgEffSumm", "Summed trigger efficiency") pad = self._GetFramedPad() pad.DrawFrame(TriggerEfficiencyFrame("tframe")) pad.DrawGraphicsObject( GraphicsObject(self.__triggereff.GetEfficiencyCurve(), Style(kBlack, 20)), False, "Trigger Eff") pad.DrawLabel(0.5, 0.2, 0.89, 0.25, "Trigger: %s" % (self.__triggername))
def Create(self): """ Creator function for the plot """ self._OpenCanvas("weightplot", "Monte-Carlo weights") pad = self._GetFramedPad() pad.GetPad().SetLogy() frame = Frame("wframe", 0., 11., 1e-12, 1e-5) frame.SetXtitle("p_{t,hard} bin") frame.SetYtitle("weight factor") pad.DrawFrame(frame) pad.DrawGraphicsObject( GraphicsObject(self.__points.GetWeightingCurve(), Style(kBlack, 20)), False, "weights")
def CreatePlot(self, trigger): """ Create the plot """ styles = [Style(kBlack, 24), Style(kBlue, 25), Style(kRed, 26), Style(kGreen, 27), Style(kMagenta, 28), Style(kOrange, 29), \ Style(kTeal, 30), Style(kViolet, 31), Style(kGray, 32), Style(kYellow + 2, 33), Style(kCyan+3, 34), Style(kRed-9, 35)] triggerCalculator = None for i in range(1, self.__nbins + 1): collection = self.__filehandler.GetCollection().GetData(i) tcname = "tracksWithClusters" #tcname = "tracksAll" triggerCalculator = TriggerEfficiency( trigger, collection.GetData("MinBias").FindTrackContainer(tcname), collection.GetData(trigger).FindTrackContainer(tcname)) self.__plotter.AddEfficiency( i, triggerCalculator.GetEfficiencyCurve(), styles[i - 1]) self.__plotter.Create() return self.__plotter
class RawSpectrumDrawer(object): styles = { "MinBias": Style(kBlack, 20), "EMCJHigh": Style(kRed, 24), "EMCJLow": Style(kOrange, 26), "EMCGHigh": Style(kBlue, 25), "EMCGLow": Style(kGreen, 27) } def __init__(self, filename, filetype="lego"): reader = ResultDataBuilder(filetype, filename) self.__data = reader.GetResults() self.__plots = {} for tracks in ["tracksAll", "tracksWithClusters"]: self.__plots[tracks] = self.MakeTrackComparisonPlot(tracks) for clusters in ["Calib", "Uncalib"]: self.__plots[clusters] = self.MakeClusterComparisonPlot(clusters) def MakeTrackComparisonPlot(self, contname): plot = PtTriggeredSpectrumComparisonPlot(contname) for trg in self.styles.keys(): plot.AddSpectrum( trg, self.MakeNormalisedSpectrum( self.__data.GetData(trg).FindTrackContainer(contname), "%s%s" % (trg, contname), True), self.styles[trg]) plot.Create() return plot def MakeClusterComparisonPlot(self, contname): plot = EnergyTriggeredSpectrumComparisonPlot(contname) nminbias = self.__data.GetData("MinBias").FindClusterContainer( contname).GetEventCount() for trg in self.styles.keys(): plot.AddSpectrum( trg, self.MakeNormalisedSpectrum( self.__data.GetData(trg).FindClusterContainer(contname), "%s%s" % (trg, contname), False), self.styles[trg]) plot.Create() return plot def MakeNormalisedSpectrum(self, spectrum, name, istrack): spectrum.SetVertexRange(-10., 10.) spectrum.SetPileupRejection(True) if istrack: spectrum.SelectTrackCuts(1) projected = spectrum.MakeProjection( 0, "rawspectrum%s" % (name), "p_{#rm{t}} (GeV/c)", "1/N_{event} 1/(#Delta p_{#rm t}) dN/dp_{#rm{t}} ((GeV/c)^{-2}") return projected def MakeNormalisedSpectrumV1(self, spectrum, name, nminbias, istrack): spectrum.SetVertexRange(-10., 10.) spectrum.SetPileupRejection(True) if istrack: spectrum.SelectTrackCuts(1) spectrum.RequestSeenInMinBias() projected = spectrum.MakeProjection( 0, "rawspectrum%s" % (name), "p_{#rm{t}} (GeV/c)", "1/N_{event} 1/(#Delta p_{#rm t}) dN/dp_{#rm{t}} ((GeV/c)^{-2}", doNorm=False) projected.Scale(nminbias) return projected def FindPlots(self, plotname): return self.__plots[plotname] def GetListOfPlots(self): return self.__plots