Public Member Functions | Private Attributes | List of all members
PandAna.core.core.spectrum Class Reference
Inheritance diagram for PandAna.core.core.spectrum:
PandAna.core.core.filledSpectrum

Public Member Functions

def __init__ (self, tables, cut, var, weight=None, name=None)
 
def fill (self)
 
def POT (self)
 
def df (self)
 
def weight (self)
 
def histogram (self, bins=None, range=None, POT=None)
 
def entries (self)
 
def integral (self, POT=None)
 
def to_text (self, fileName, sep=' ', header=False)
 
def __add__ (self, b)
 
def __and__ (self, b)
 

Private Attributes

 _name
 
 _varfcn
 
 _cutfcn
 
 _weightfcn
 
 _tables
 
 _cut
 
 _df
 
 _weight
 
 _POT
 

Detailed Description

Definition at line 14 of file core.py.

Constructor & Destructor Documentation

def PandAna.core.core.spectrum.__init__ (   self,
  tables,
  cut,
  var,
  weight = None,
  name = None 
)

Definition at line 15 of file core.py.

Referenced by PandAna.core.core.spectrum.fill().

15  def __init__(self, tables, cut, var, weight=None, name=None):
16  self._name = name
17 
18  # save the var and cut functions so we can call __init__ during fill
19  self._varfcn = var
20  self._cutfcn = cut
21  self._weightfcn = weight
22 
23  # keep a reference to loader for fill
24  self._tables = tables
25 
26  # associate this spectrum, cut with loader for filling
27  tables.add_spectrum(self)
28 
29  # compute cut, var, and weights
30  # tables is an empty cache of all the necessary branches and leaves initially
31  # after tables.Go() the branches and leaves are filled with data from the files given
32  self._cut = cut(self._tables)
33  self._df = var(self._tables)
34  self._df = self._df.dropna()
35 
36  # initial weights are all 1
37  self._weight = pd.Series(1, self._df.index, name='weight')
38  if weight:
39  # apply all the weights
40  if type(weight) is list:
41  for w in weight:
42  self._weight = w(tables, self._weight)
43  else: self._weight = weight(tables, self._weight)
44 
def __init__(self, tables, cut, var, weight=None, name=None)
Definition: core.py:15
const Cut cut
Definition: exporter_fd.C:30
Float_t w
Definition: plot.C:20

Member Function Documentation

def PandAna.core.core.spectrum.__add__ (   self,
  b 
)

Definition at line 85 of file core.py.

References PandAna.core.core.spectrum._df, novaddt::SlowMMTrigger._df, and PandAna.core.core.spectrum._POT.

85  def __add__(self, b):
86  df = pd.concat([self._df, b._df])
87  pot = self._POT + b._POT
88  return filledSpectrum(df, pot)
89 
def __add__(self, b)
Definition: core.py:85
def PandAna.core.core.spectrum.__and__ (   self,
  b 
)

Definition at line 90 of file core.py.

References PandAna.core.core.spectrum._df, novaddt::SlowMMTrigger._df, PandAna.core.core.spectrum._POT, PandAna.core.core.spectrum._weight, and makeHists._weight.

90  def __and__(self, b):
91  assert self._POT == b._POT, "Spectra should have same POT"
92  if self._weight is not None and b._weight is not None:
93  assert np.array_equal(self._weight, b._weight), "Spectra should have same weights"
94 
95  df = pd.concat([self._df, b._df], axis=1)
96  pot = self._POT
97  weight = self._weight
98  return filledSpectrum(df, pot, weight=weight)
99 
100 
101 # For constructing spectra without having to fill
def __and__(self, b)
Definition: core.py:90
def PandAna.core.core.spectrum.df (   self)

Definition at line 64 of file core.py.

References PandAna.core.core.spectrum._df, and novaddt::SlowMMTrigger._df.

64  def df(self):
65  return self._df
66 
def PandAna.core.core.spectrum.entries (   self)

Definition at line 75 of file core.py.

75  def entries(self):
76  return self._df.shape[0]
77 
def PandAna.core.core.spectrum.fill (   self)

Definition at line 45 of file core.py.

References allpot.style.Style.__init__(), confusionMatrixTree.lmdb_reader.__init__(), nuray.Nuray.__init__(), plotConfusion.HistSet.__init__(), ancestor.Ancestor.__init__(), vdbl.Vdbl.__init__(), PandAna.core.core.spectrum.__init__(), checkCalibrationCSV.NovaCalibTest.__init__(), tgtexit.Tgtexit.__init__(), samweb_client.http_client_requests.RequestsHTTPClient.__init__(), decay.Decay.__init__(), bp_database.BlessedPlotsDB.__init__(), bp_plot.Plot.__init__(), drawEvents.HistSet.__init__(), samweb_client.http_client_urllib2.Response.__init__(), samweb_client.http_client.SAMWebHTTPClient.__init__(), cafana.PyCAFAna.__init__(), samweb_client._exceptions.SAMWebHTTPError.__init__(), run_unfold_ppfx_multiprocess.Consumer.__init__(), plot_validation_datamc.Spectrum.__init__(), makeTrainCVSamples.FilePair.__init__(), run_unfold_systs_multiprocess.Consumer.__init__(), run_unfold_genie_multiprocess.Consumer.__init__(), bp_docdb.Document.__init__(), samweb_client._exceptions.GenericHTTPError.__init__(), samweb_client.client.SAMWebClient.__init__(), samweb_client._exceptions.HTTPBadRequest.__init__(), run_unfold_ppfx_multiprocess.Task.__init__(), run_unfold_systs_multiprocess.Task.__init__(), samweb_client._exceptions.HTTPForbidden.__init__(), WatchdogFx.Connection.__init__(), run_unfold_genie_multiprocess.Task.__init__(), TB_WatchdogFx.Connection.__init__(), samweb_client._exceptions.HTTPNotFound.__init__(), plot_validation_datamc.Prediction.__init__(), samweb_client._exceptions.HTTPConflict.__init__(), lem_server.ConnInfo.__init__(), bp_docdb.DocDB.__init__(), samweb_client.http_client_urllib2.HTTPSClientAuthHandler.__init__(), plot_validation_datamc_2018.Spectrum.__init__(), samweb_client._exceptions._Exceptions.__init__(), std_candles.StdCandlesPlotter.__init__(), plot_validation_datamc.Ratio.__init__(), plot_validation_datamc_2018.Prediction.__init__(), samweb_client.http_client_urllib2.LoggingRequest.__init__(), plot_validation_datamc_2018.Ratio.__init__(), samweb_client.http_client_urllib2.RequestWithMethod.__init__(), samweb_client.http_client_urllib2.URLLib2HTTPClient.__init__(), gen_flatrecord.TypeName.__init__(), canMan.ProgressTracker.__init__(), TB_WatchdogFx.Tier.__init__(), WatchdogFx.Tier.__init__(), txt_utils.PixelmapGenerator.__init__(), TB_WatchdogFx.Path.__init__(), WatchdogFx.Path.__init__(), fabricate.AtimesRunner.__init__(), canMan.Table.__init__(), fabricate.StraceProcess.__init__(), std_candles.PlotConfig.__init__(), std_candles.DataMCPlots.__init__(), fabricate.StraceRunner.__init__(), fabricate.AlwaysRunner.__init__(), fabricate.SmartRunner.__init__(), fabricate._running.__init__(), fabricate._after.__init__(), fabricate._Groups.value.__init__(), fabricate._Groups.__init__(), fabricate._todo.__init__(), fabricate.Builder.__init__(), PandAna.core.core.spectrum._cutfcn, PandAna.core.core.spectrum._df, novaddt::SlowMMTrigger._df, PandAna.core.core.spectrum._name, nl::NearlinePlot._name, NdmcMetric< T >._name, PandAna.core.core.spectrum._tables, PandAna.core.core.spectrum._varfcn, and PandAna.core.core.spectrum._weightfcn.

45  def fill(self):
46  # loader.Go() has been called
47  self.__init__(self._tables, self._cutfcn, self._varfcn, weight=self._weightfcn, name=self._name)
48 
49  # Just to be sure...
50  assert np.array_equal(self._df.index, self._weight.index), 'var and weights have different rows'
51 
52  # reset tables global index
53  self._tables.reset_index()
54 
55  # Set dataframe name if desired
56  if self._name: self._df = self._df.rename(self._name)
57 
58  # Grab spectrum POT from tables
59  self._POT = self._tables._POT
60 
def __init__(self, tables, cut, var, weight=None, name=None)
Definition: core.py:15
def PandAna.core.core.spectrum.histogram (   self,
  bins = None,
  range = None,
  POT = None 
)

Definition at line 70 of file core.py.

References PandAna.core.core.spectrum._df, novaddt::SlowMMTrigger._df, PandAna.core.core.spectrum._POT, PandAna.core.core.spectrum._weight, and makeHists._weight.

70  def histogram(self, bins=None, range=None, POT=None):
71  if not POT: POT = self._POT
72  n, bins = np.histogram(self._df, bins, range, weights = self._weight)
73  return n*POT/self._POT, bins
74 
def histogram(self, bins=None, range=None, POT=None)
Definition: core.py:70
def PandAna.core.core.spectrum.integral (   self,
  POT = None 
)

Definition at line 78 of file core.py.

References PandAna.core.core.spectrum._POT.

78  def integral(self,POT=None):
79  if not POT: POT = self._POT
80  return self._weight.sum()*POT/self._POT
81 
def integral(self, POT=None)
Definition: core.py:78
def PandAna.core.core.spectrum.POT (   self)

Definition at line 61 of file core.py.

References PandAna.core.core.spectrum._POT.

61  def POT(self):
62  return self._POT
63 
def PandAna.core.core.spectrum.to_text (   self,
  fileName,
  sep = ' ',
  header = False 
)

Definition at line 82 of file core.py.

82  def to_text(self, fileName, sep=' ', header=False):
83  self._df.to_csv(fileName, sep=sep, index=True, header=header)
84 
def to_text(self, fileName, sep=' ', header=False)
Definition: core.py:82
def PandAna.core.core.spectrum.weight (   self)

Definition at line 67 of file core.py.

References PandAna.core.core.spectrum._weight, and makeHists._weight.

67  def weight(self):
68  return self._weight
69 

Member Data Documentation

PandAna.core.core.spectrum._cut
private
PandAna.core.core.spectrum._cutfcn
private

Definition at line 20 of file core.py.

Referenced by PandAna.core.core.spectrum.fill().

PandAna.core.core.spectrum._df
private
PandAna.core.core.spectrum._name
private

Definition at line 16 of file core.py.

Referenced by PandAna.core.core.spectrum.fill().

PandAna.core.core.spectrum._POT
private
PandAna.core.core.spectrum._tables
private
PandAna.core.core.spectrum._varfcn
private

Definition at line 19 of file core.py.

Referenced by PandAna.core.core.spectrum.fill().

PandAna.core.core.spectrum._weight
private
PandAna.core.core.spectrum._weightfcn
private

Definition at line 21 of file core.py.

Referenced by PandAna.core.core.spectrum.fill().


The documentation for this class was generated from the following file: