Public Member Functions | Public Attributes | List of all members
generic.controllers.MakeCanvases.HistogramExtractor Class Reference
Inheritance diagram for generic.controllers.MakeCanvases.HistogramExtractor:
object

Public Member Functions

def __init__ (self, accept_filters=[], reject_filters=[])
 
def KeepHist (self, name)
 
def ExtractHistsFromDirectory (self, tdirectory, base_path="")
 

Public Attributes

 accept_filters
 
 reject_filters
 
short int type
 
short int number
 
char name [SIZE_OF_OBJ_NAME]
 
cat_entry star
 

Detailed Description

Definition at line 96 of file MakeCanvases.py.

Constructor & Destructor Documentation

def generic.controllers.MakeCanvases.HistogramExtractor.__init__ (   self,
  accept_filters = [],
  reject_filters = [] 
)

Definition at line 97 of file MakeCanvases.py.

97  def __init__(self, accept_filters=[], reject_filters=[]):
98  self.accept_filters = accept_filters
99  self.reject_filters = reject_filters
100 
def __init__(self, accept_filters=[], reject_filters=[])
Definition: MakeCanvases.py:97

Member Function Documentation

def generic.controllers.MakeCanvases.HistogramExtractor.ExtractHistsFromDirectory (   self,
  tdirectory,
  base_path = "" 
)

Definition at line 108 of file MakeCanvases.py.

References Exposure(), generic.controllers.MakeCanvases.HistogramExtractor.ExtractHistsFromDirectory(), GetName(), generic.controllers.MakeCanvases.HistogramExtractor.KeepHist(), SetTitle(), and submit_syst.str.

Referenced by generic.controllers.MakeCanvases.HistogramExtractor.ExtractHistsFromDirectory().

108  def ExtractHistsFromDirectory(self, tdirectory, base_path=""):
109  for tkey in tdirectory.GetListOfKeys():
110  obj = tkey.ReadObj()
111  name = obj.GetName()
112 
113  if isinstance(obj, ROOT.TH1) and self.KeepHist(name):
114  splitted = name.rsplit("/", 1)
115  if len(splitted) > 1:
116  path, name = splitted
117  obj.SetName(name)
118  else:
119  path = ""
120  obj.exposure = None
121  yield base_path + ("/" if base_path and path else "") + path, (NO_DIR >> obj)
122 
123  # these were CAFAna Spectra, once
124  elif isinstance(obj, ROOT.TDirectory) and \
125  obj.Get("type") and \
126  obj.Get("type").GetName() == "Spectrum" and \
127  self.KeepHist(obj.GetName()):
128  h = obj.Get("hist")
129  args = {
130  "POT": obj.Get("pot"),
131  "livetime": obj.Get("livetime"),
132  }
133  for exp_type, hist in args.items():
134  args[exp_type] = None if hist.GetBinContent(1) == 0 else hist.GetBinContent(1)
135  h.exposure = Exposure(**args)
136  h.SetName(obj.GetName())
137 
138  # labels for new-style CAFs are stored separately
139  for label_idx, axis_name in enumerate("XYZ"):
140  title = obj.Get("label%d" % label_idx)
141  if title:
142  getattr(h, "Get%saxis" % axis_name)().SetTitle(str(title))
143 
144  yield base_path, (NO_DIR >> h)
145 
146  elif isinstance(obj, ROOT.TDirectory):
147  path = name if not base_path else "/".join((base_path, name))
148  for path, h in self.ExtractHistsFromDirectory(obj, base_path=path):
149  yield path, (NO_DIR >> h)
150 
void Exposure()
Definition: getTimePeak.C:54
gargamelle SetTitle("Gargamelle #nu_{e} CC data")
std::string GetName(int i)
def ExtractHistsFromDirectory(self, tdirectory, base_path="")
def generic.controllers.MakeCanvases.HistogramExtractor.KeepHist (   self,
  name 
)

Member Data Documentation

generic.controllers.MakeCanvases.HistogramExtractor.accept_filters
char object::name
inherited
short int object::number
inherited

Definition at line 115 of file novas.h.

generic.controllers.MakeCanvases.HistogramExtractor.reject_filters
cat_entry object::star
inherited

Definition at line 117 of file novas.h.

short int object::type
inherited

Definition at line 114 of file novas.h.


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