CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes
PerformanceCurvePlotter.TauValidationInfo Class Reference

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)
 

Detailed Description

Atomic object to hold information about where files are located, which discriminants to plot 

Definition at line 66 of file PerformanceCurvePlotter.py.

Constructor & Destructor Documentation

def PerformanceCurvePlotter.TauValidationInfo.__init__ (   self,
  SignalFile,
  BackgroundFile,
  Label,
  ValidationProducer 
)

Definition at line 79 of file PerformanceCurvePlotter.py.

79 
80  def __init__(self, SignalFile, BackgroundFile, Label, ValidationProducer):
81  self.Label = Label
82  self.SignalFile = TFile.Open(SignalFile)
83  self.BackgroundFile = TFile.Open(BackgroundFile)
84  self.ValidationProducer = ValidationProducer
85  self.InfoDictionary = { 'producer' : self.ValidationProducer.TauProducer.value(),
86  'label' : self.ValidationProducer.ExtensionName.value(),
87  'var' : KinematicVar }
88 
89  # Store each discriminator as a point. Initally, retrieve the names. Each discriminator will eventual be a tuple holding the effs/fake rates etc
90  self.DiscriminatorPoints = [ {'name' : DiscInfo.discriminator.value().replace(self.InfoDictionary['producer'].replace('Producer', ''), '').replace('Discrimination', ''),
91  'loc' : self.BuildFullPathForDiscriminator(DiscInfo.discriminator.value()) } for DiscInfo in ValidationProducer.discriminators.value() ]
92  if HideMuonAndElectronRej:
93  NewPoints = []
94  for aPoint in self.DiscriminatorPoints:
95  if aPoint['name'].find("Electron") == -1 and aPoint['name'].find("Muon") == -1:
96  NewPoints.append(aPoint)
97  self.DiscriminatorPoints = NewPoints
98 
99  # Add denominator info
100  self.Denominator = {'loc' : "DQMData/RecoTauV/%(producer)s%(label)s_ReferenceCollection/nRef_Taus_vs_%(var)sTauVisible" % self.InfoDictionary }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7

Member Function Documentation

def PerformanceCurvePlotter.TauValidationInfo.BuildFullPathForDiscriminator (   self,
  DiscName 
)

Definition at line 101 of file PerformanceCurvePlotter.py.

References PerformanceCurvePlotter.TauValidationInfo.InfoDictionary.

102  def BuildFullPathForDiscriminator(self, DiscName):
103  self.InfoDictionary['disc'] = DiscName
104  output = "DQMData/RecoTauV/%(producer)s%(label)s_%(disc)s/%(disc)s_vs_%(var)sTauVisible" % self.InfoDictionary
105  del self.InfoDictionary['disc']
return output
def PerformanceCurvePlotter.TauValidationInfo.BuildTGraphSummary (   self)

Definition at line 173 of file PerformanceCurvePlotter.py.

174  def BuildTGraphSummary(self):
175  print "Building summary"
176  self.SummaryTGraph = TGraph(len(self.DiscriminatorPoints))
177  for index, aPoint in enumerate(self.DiscriminatorPoints):
178  self.SummaryTGraph.SetPoint(index, aPoint['SignalEff'], aPoint['BackgroundEff'])
179  self.SummaryTGraph.SetLineColor(TauValidationInfo.StaticSummaryLineColorIterator)
180  self.SummaryTGraph.SetLineWidth(2)
181  self.SummaryLegend.AddEntry( self.SummaryTGraph, self.Label,"L")
182  TauValidationInfo.StaticSummaryLineColorIterator += 1
183 
def PerformanceCurvePlotter.TauValidationInfo.ComputeEfficiencies (   self)

Definition at line 133 of file PerformanceCurvePlotter.py.

References PerformanceCurvePlotter.TauValidationInfo.Denominator, PerformanceCurvePlotter.TauValidationInfo.DiscriminatorPoints, QualityTester.Label, and PerformanceCurvePlotter.TauValidationInfo.Label.

134  def ComputeEfficiencies(self):
135  print "Computing efficiencies for %s" % self.Label
136  print "-----------------------------------------------------"
137  print "%-40s %10s %10s" % ("Discriminator", "SignalEff", "FakeRate")
138  print "-----------------------------------------------------"
139  # Get denominators
140  SignalDenominatorHisto = self.Denominator['SignalHistoRebin']
141  BackgroundDenominatorHisto = self.Denominator['BackgroundHistoRebin']
142  for aPoint in self.DiscriminatorPoints:
143  SignalPointHisto = aPoint['SignalHistoRebin']
144  BackgroundPointHisto = aPoint['BackgroundHistoRebin']
145  # compute length 1 TGraphAsymmErrors, to compute the errors correctly
146  TempSignalEffPoint = TGraphAsymmErrors(SignalPointHisto, SignalDenominatorHisto)
147  TempBackgroundEffPoint = TGraphAsymmErrors(BackgroundPointHisto, BackgroundDenominatorHisto)
148  # Create a new TGraphAsymmErrors, where the x and y coordinates are the Signal/Background efficiencies, respectively
149  PerformancePoint = TGraphAsymmErrors(1) #only one point
150  xValueSignal = Double(0) #stupid root pass by reference crap
151  yValueSignal = Double(0)
152  xValueBackground = Double(0)
153  yValueBackground = Double(0)
154  TempSignalEffPoint.GetPoint(0, xValueSignal, yValueSignal)
155  TempBackgroundEffPoint.GetPoint(0, xValueBackground, yValueBackground)
156  aPoint['SignalEff'] = yValueSignal
157  aPoint['BackgroundEff'] = yValueBackground
158  print "%-40s %10.3f %10.4f" % (aPoint['name'], aPoint['SignalEff'], aPoint['BackgroundEff'])
159  PerformancePoint.SetPoint(0, yValueSignal, yValueBackground)
160  PerformancePoint.SetPointError(0,
161  TempSignalEffPoint.GetErrorYlow(0), #ex low
162  TempSignalEffPoint.GetErrorYhigh(0), #ex high
163  TempBackgroundEffPoint.GetErrorYlow(0), #ey low
164  TempBackgroundEffPoint.GetErrorYhigh(0) ) #ey high
165  PerformancePoint.SetMarkerSize(2)
166  try:
167  PerformancePoint.SetMarkerStyle(TauValidationInfo.DiscriminatorToMarkerStyleDict[aPoint['name']])
168  except KeyError:
169  PerformancePoint.SetMarkerStyle(TauValidationInfo.StaticMarkerStyleIterator)
170  TauValidationInfo.DiscriminatorToMarkerStyleDict[aPoint['name']] = TauValidationInfo.StaticMarkerStyleIterator
171  self.DiscriminatorLegend.AddEntry( PerformancePoint, aPoint['name'],"P")
172  TauValidationInfo.StaticMarkerStyleIterator += 1
aPoint['PerformancePoint'] = PerformancePoint
def PerformanceCurvePlotter.TauValidationInfo.LoadHistograms (   self)

Definition at line 115 of file PerformanceCurvePlotter.py.

References PerformanceCurvePlotter.TauValidationInfo.Denominator, PerformanceCurvePlotter.TauValidationInfo.DiscriminatorPoints, QualityTester.Label, PerformanceCurvePlotter.TauValidationInfo.Label, and PerformanceCurvePlotter.TauValidationInfo.RebinHistogram().

116  def LoadHistograms(self):
117  # Load original histograms, and rebin them if necessary
118  # Get denominator
119  print "Loading histograms for %s" % self.Label
120  SignalDenominatorHisto = self.SignalFile.Get(self.Denominator['loc'])
121  self.Denominator['SignalHisto'] = SignalDenominatorHisto
122  self.Denominator['SignalHistoRebin'] = self.RebinHistogram(SignalDenominatorHisto, KinematicVarMin, KinematicVarMax)
123  BackgroundDenominatorHisto = self.BackgroundFile.Get(self.Denominator['loc'])
124  self.Denominator['BackgroundHisto'] = BackgroundDenominatorHisto
125  self.Denominator['BackgroundHistoRebin'] = self.RebinHistogram(BackgroundDenominatorHisto, KinematicVarMin, KinematicVarMax)
126  # Get numerators
127  for aPoint in self.DiscriminatorPoints:
128  SignalPointHisto = self.SignalFile.Get(aPoint['loc'])
129  aPoint['SignalHisto'] = SignalPointHisto
130  aPoint['SignalHistoRebin'] = self.RebinHistogram(SignalPointHisto, KinematicVarMin, KinematicVarMax)
131  BackgroundPointHisto = self.BackgroundFile.Get(aPoint['loc'])
132  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.

Referenced by PerformanceCurvePlotter.TauValidationInfo.LoadHistograms().

107  def RebinHistogram(self, Histo, MinBinValue, MaxBinValue):
108  """ Rebin a range of an input histogram into a new histogram w/ 1 bin. """
109  OutputHisto = TH1F("temp_%i" % TauValidationInfo.StupidRootStupidNameCounter, "temp", 1, MinBinValue, MaxBinValue)
110  TauValidationInfo.StupidRootStupidNameCounter += 1
111  MinBinNumber = Histo.FindBin(MinBinValue)
112  MaxBinNumber = Histo.FindBin(MaxBinValue)
113  #print "Integrating histogram between values (%f, %f)" % (Histo.GetBinLowEdge(MinBinNumber), Histo.GetBinLowEdge(MaxBinNumber)+Histo.GetBinWidth(MaxBinNumber))
114  OutputHisto.SetBinContent(1,Histo.Integral(MinBinNumber, MaxBinNumber))
return OutputHisto

Member Data Documentation

PerformanceCurvePlotter.TauValidationInfo.BackgroundFile

Definition at line 82 of file PerformanceCurvePlotter.py.

PerformanceCurvePlotter.TauValidationInfo.Denominator

Definition at line 99 of file PerformanceCurvePlotter.py.

Referenced by PerformanceCurvePlotter.TauValidationInfo.ComputeEfficiencies(), and PerformanceCurvePlotter.TauValidationInfo.LoadHistograms().

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.

PerformanceCurvePlotter.TauValidationInfo.DiscriminatorPoints

Definition at line 89 of file PerformanceCurvePlotter.py.

Referenced by PerformanceCurvePlotter.TauValidationInfo.ComputeEfficiencies(), and PerformanceCurvePlotter.TauValidationInfo.LoadHistograms().

dictionary PerformanceCurvePlotter.TauValidationInfo.DiscriminatorToMarkerStyleDict = {}
static

Definition at line 68 of file PerformanceCurvePlotter.py.

PerformanceCurvePlotter.TauValidationInfo.InfoDictionary

Definition at line 84 of file PerformanceCurvePlotter.py.

Referenced by PerformanceCurvePlotter.TauValidationInfo.BuildFullPathForDiscriminator().

PerformanceCurvePlotter.TauValidationInfo.Label

Definition at line 80 of file PerformanceCurvePlotter.py.

Referenced by PerformanceCurvePlotter.TauValidationInfo.ComputeEfficiencies(), and PerformanceCurvePlotter.TauValidationInfo.LoadHistograms().

PerformanceCurvePlotter.TauValidationInfo.SignalFile

Definition at line 81 of file PerformanceCurvePlotter.py.

int PerformanceCurvePlotter.TauValidationInfo.StaticMarkerStyleIterator = 20
static

Definition at line 69 of file PerformanceCurvePlotter.py.

int PerformanceCurvePlotter.TauValidationInfo.StaticSummaryLineColorIterator = 2
static

Definition at line 70 of file PerformanceCurvePlotter.py.

int PerformanceCurvePlotter.TauValidationInfo.StupidRootStupidNameCounter = 0
static

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.

PerformanceCurvePlotter.TauValidationInfo.SummaryTGraph

Definition at line 175 of file PerformanceCurvePlotter.py.

PerformanceCurvePlotter.TauValidationInfo.ValidationProducer

Definition at line 83 of file PerformanceCurvePlotter.py.