Public Member Functions | |
def | __init__ |
def | BuildFullPathForDiscriminator |
def | BuildTGraphSummary |
def | ComputeEfficiencies |
def | LoadHistograms |
def | RebinHistogram |
Public Attributes | |
BackgroundFile | |
Denominator | |
DiscriminatorPoints | |
InfoDictionary | |
Label | |
SignalFile | |
SummaryTGraph | |
ValidationProducer | |
Static Public Attributes | |
int | DiscriminatorBackground = 0 |
tuple | DiscriminatorLegend = TLegend(0.15, 0.6, 0.5, 0.92) |
dictionary | DiscriminatorToMarkerStyleDict = {} |
int | StaticMarkerStyleIterator = 20 |
int | StaticSummaryLineColorIterator = 2 |
int | StupidRootStupidNameCounter = 0 |
int | SummaryBackground = 0 |
tuple | SummaryLegend = TLegend(0.6, 0.3, 0.9, 0.4) |
Atomic object to hold information about where files are located, which discriminants to plot
Definition at line 66 of file PerformanceCurvePlotter.py.
def PerformanceCurvePlotter::TauValidationInfo::__init__ | ( | self, | |
SignalFile, | |||
BackgroundFile, | |||
Label, | |||
ValidationProducer | |||
) |
Definition at line 79 of file PerformanceCurvePlotter.py.
00080 : 00081 self.Label = Label 00082 self.SignalFile = TFile.Open(SignalFile) 00083 self.BackgroundFile = TFile.Open(BackgroundFile) 00084 self.ValidationProducer = ValidationProducer 00085 self.InfoDictionary = { 'producer' : self.ValidationProducer.TauProducer.value(), 00086 'label' : self.ValidationProducer.ExtensionName.value(), 00087 'var' : KinematicVar } 00088 00089 # Store each discriminator as a point. Initally, retrieve the names. Each discriminator will eventual be a tuple holding the effs/fake rates etc 00090 self.DiscriminatorPoints = [ {'name' : DiscInfo.discriminator.value().replace(self.InfoDictionary['producer'].replace('Producer', ''), '').replace('Discrimination', ''), 00091 'loc' : self.BuildFullPathForDiscriminator(DiscInfo.discriminator.value()) } for DiscInfo in ValidationProducer.discriminators.value() ] 00092 if HideMuonAndElectronRej: 00093 NewPoints = [] 00094 for aPoint in self.DiscriminatorPoints: 00095 if aPoint['name'].find("Electron") == -1 and aPoint['name'].find("Muon") == -1: 00096 NewPoints.append(aPoint) 00097 self.DiscriminatorPoints = NewPoints 00098 00099 # Add denominator info 00100 self.Denominator = {'loc' : "DQMData/RecoTauV/%(producer)s%(label)s_ReferenceCollection/nRef_Taus_vs_%(var)sTauVisible" % self.InfoDictionary }
def PerformanceCurvePlotter::TauValidationInfo::BuildFullPathForDiscriminator | ( | self, | |
DiscName | |||
) |
Definition at line 101 of file PerformanceCurvePlotter.py.
def PerformanceCurvePlotter::TauValidationInfo::BuildTGraphSummary | ( | self | ) |
Definition at line 173 of file PerformanceCurvePlotter.py.
00174 : 00175 print "Building summary" 00176 self.SummaryTGraph = TGraph(len(self.DiscriminatorPoints)) 00177 for index, aPoint in enumerate(self.DiscriminatorPoints): 00178 self.SummaryTGraph.SetPoint(index, aPoint['SignalEff'], aPoint['BackgroundEff']) 00179 self.SummaryTGraph.SetLineColor(TauValidationInfo.StaticSummaryLineColorIterator) 00180 self.SummaryTGraph.SetLineWidth(2) 00181 self.SummaryLegend.AddEntry( self.SummaryTGraph, self.Label,"L") 00182 TauValidationInfo.StaticSummaryLineColorIterator += 1 00183
def PerformanceCurvePlotter::TauValidationInfo::ComputeEfficiencies | ( | self | ) |
Definition at line 133 of file PerformanceCurvePlotter.py.
00134 : 00135 print "Computing efficiencies for %s" % self.Label 00136 print "-----------------------------------------------------" 00137 print "%-40s %10s %10s" % ("Discriminator", "SignalEff", "FakeRate") 00138 print "-----------------------------------------------------" 00139 # Get denominators 00140 SignalDenominatorHisto = self.Denominator['SignalHistoRebin'] 00141 BackgroundDenominatorHisto = self.Denominator['BackgroundHistoRebin'] 00142 for aPoint in self.DiscriminatorPoints: 00143 SignalPointHisto = aPoint['SignalHistoRebin'] 00144 BackgroundPointHisto = aPoint['BackgroundHistoRebin'] 00145 # compute length 1 TGraphAsymmErrors, to compute the errors correctly 00146 TempSignalEffPoint = TGraphAsymmErrors(SignalPointHisto, SignalDenominatorHisto) 00147 TempBackgroundEffPoint = TGraphAsymmErrors(BackgroundPointHisto, BackgroundDenominatorHisto) 00148 # Create a new TGraphAsymmErrors, where the x and y coordinates are the Signal/Background efficiencies, respectively 00149 PerformancePoint = TGraphAsymmErrors(1) #only one point 00150 xValueSignal = Double(0) #stupid root pass by reference crap 00151 yValueSignal = Double(0) 00152 xValueBackground = Double(0) 00153 yValueBackground = Double(0) 00154 TempSignalEffPoint.GetPoint(0, xValueSignal, yValueSignal) 00155 TempBackgroundEffPoint.GetPoint(0, xValueBackground, yValueBackground) 00156 aPoint['SignalEff'] = yValueSignal 00157 aPoint['BackgroundEff'] = yValueBackground 00158 print "%-40s %10.3f %10.4f" % (aPoint['name'], aPoint['SignalEff'], aPoint['BackgroundEff']) 00159 PerformancePoint.SetPoint(0, yValueSignal, yValueBackground) 00160 PerformancePoint.SetPointError(0, 00161 TempSignalEffPoint.GetErrorYlow(0), #ex low 00162 TempSignalEffPoint.GetErrorYhigh(0), #ex high 00163 TempBackgroundEffPoint.GetErrorYlow(0), #ey low 00164 TempBackgroundEffPoint.GetErrorYhigh(0) ) #ey high 00165 PerformancePoint.SetMarkerSize(2) 00166 try: 00167 PerformancePoint.SetMarkerStyle(TauValidationInfo.DiscriminatorToMarkerStyleDict[aPoint['name']]) 00168 except KeyError: 00169 PerformancePoint.SetMarkerStyle(TauValidationInfo.StaticMarkerStyleIterator) 00170 TauValidationInfo.DiscriminatorToMarkerStyleDict[aPoint['name']] = TauValidationInfo.StaticMarkerStyleIterator 00171 self.DiscriminatorLegend.AddEntry( PerformancePoint, aPoint['name'],"P") 00172 TauValidationInfo.StaticMarkerStyleIterator += 1 aPoint['PerformancePoint'] = PerformancePoint
def PerformanceCurvePlotter::TauValidationInfo::LoadHistograms | ( | self | ) |
Definition at line 115 of file PerformanceCurvePlotter.py.
00116 : 00117 # Load original histograms, and rebin them if necessary 00118 # Get denominator 00119 print "Loading histograms for %s" % self.Label 00120 SignalDenominatorHisto = self.SignalFile.Get(self.Denominator['loc']) 00121 self.Denominator['SignalHisto'] = SignalDenominatorHisto 00122 self.Denominator['SignalHistoRebin'] = self.RebinHistogram(SignalDenominatorHisto, KinematicVarMin, KinematicVarMax) 00123 BackgroundDenominatorHisto = self.BackgroundFile.Get(self.Denominator['loc']) 00124 self.Denominator['BackgroundHisto'] = BackgroundDenominatorHisto 00125 self.Denominator['BackgroundHistoRebin'] = self.RebinHistogram(BackgroundDenominatorHisto, KinematicVarMin, KinematicVarMax) 00126 # Get numerators 00127 for aPoint in self.DiscriminatorPoints: 00128 SignalPointHisto = self.SignalFile.Get(aPoint['loc']) 00129 aPoint['SignalHisto'] = SignalPointHisto 00130 aPoint['SignalHistoRebin'] = self.RebinHistogram(SignalPointHisto, KinematicVarMin, KinematicVarMax) 00131 BackgroundPointHisto = self.BackgroundFile.Get(aPoint['loc']) 00132 aPoint['BackgroundHisto'] = BackgroundPointHisto aPoint['BackgroundHistoRebin'] = self.RebinHistogram(BackgroundPointHisto, KinematicVarMin, KinematicVarMax)
def PerformanceCurvePlotter::TauValidationInfo::RebinHistogram | ( | self, | |
Histo, | |||
MinBinValue, | |||
MaxBinValue | |||
) |
Rebin a range of an input histogram into a new histogram w/ 1 bin.
Definition at line 106 of file PerformanceCurvePlotter.py.
00107 : 00108 """ Rebin a range of an input histogram into a new histogram w/ 1 bin. """ 00109 OutputHisto = TH1F("temp_%i" % TauValidationInfo.StupidRootStupidNameCounter, "temp", 1, MinBinValue, MaxBinValue) 00110 TauValidationInfo.StupidRootStupidNameCounter += 1 00111 MinBinNumber = Histo.FindBin(MinBinValue) 00112 MaxBinNumber = Histo.FindBin(MaxBinValue) 00113 #print "Integrating histogram between values (%f, %f)" % (Histo.GetBinLowEdge(MinBinNumber), Histo.GetBinLowEdge(MaxBinNumber)+Histo.GetBinWidth(MaxBinNumber)) 00114 OutputHisto.SetBinContent(1,Histo.Integral(MinBinNumber, MaxBinNumber)) return OutputHisto
Definition at line 79 of file PerformanceCurvePlotter.py.
Definition at line 79 of file PerformanceCurvePlotter.py.
int PerformanceCurvePlotter::TauValidationInfo::DiscriminatorBackground = 0 [static] |
Definition at line 74 of file PerformanceCurvePlotter.py.
tuple PerformanceCurvePlotter::TauValidationInfo::DiscriminatorLegend = TLegend(0.15, 0.6, 0.5, 0.92) [static] |
Definition at line 72 of file PerformanceCurvePlotter.py.
Definition at line 79 of file PerformanceCurvePlotter.py.
dictionary PerformanceCurvePlotter::TauValidationInfo::DiscriminatorToMarkerStyleDict = {} [static] |
Definition at line 68 of file PerformanceCurvePlotter.py.
Definition at line 79 of file PerformanceCurvePlotter.py.
Definition at line 79 of file PerformanceCurvePlotter.py.
Definition at line 79 of file PerformanceCurvePlotter.py.
int PerformanceCurvePlotter::TauValidationInfo::StaticMarkerStyleIterator = 20 [static] |
Definition at line 69 of file PerformanceCurvePlotter.py.
Definition at line 70 of file PerformanceCurvePlotter.py.
Definition at line 71 of file PerformanceCurvePlotter.py.
int PerformanceCurvePlotter::TauValidationInfo::SummaryBackground = 0 [static] |
Definition at line 78 of file PerformanceCurvePlotter.py.
tuple PerformanceCurvePlotter::TauValidationInfo::SummaryLegend = TLegend(0.6, 0.3, 0.9, 0.4) [static] |
Definition at line 75 of file PerformanceCurvePlotter.py.
Definition at line 173 of file PerformanceCurvePlotter.py.
Definition at line 79 of file PerformanceCurvePlotter.py.