Skip to content

Commit

Permalink
Merge pull request #22 from kit-cn-cms/dev_philip
Browse files Browse the repository at this point in the history
Dev philip
  • Loading branch information
pkausw authored Jan 13, 2019
2 parents 35fdabb + 4848e16 commit d278321
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base/fileHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ def load_histogram(self, histname):
print "DEBUG: entering 'fileHandler.load_histogram'"
if self._file:
if self._debug >= 10:
print "DEBUG: loading histogram '%s' from '%s'" % (histname, file)
print "DEBUG: loading histogram '%s' from '%s'" % (histname, self._file.GetName())
h = self._file.Get(histname)
if isinstance(h, TH1):
return h
else:
print ("WARNING: histogram '%s' does not exist in '%s'"
% (histname, file))
% (histname, self._file.GetName()))
else:
print "ERROR: In fileHandler - file is not set!"
return None
Expand Down
13 changes: 13 additions & 0 deletions src/datacardMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ def write_keyword_process_lines(self,category,size,sizekeys):
if not file=="" and not key_nominal_hist=="" and not key_systematic_hist=="":
line.append(self.write_keyword_block_line(process_name=process,category_name=category.name,file=file,
nominal_key=key_nominal_hist,syst_key=key_systematic_hist,size=size,sizekeys=sizekeys))
data_obs = category.observation
if not data_obs is None and not data_obs.file == category.default_file:
file = data_obs.file
key_nominal_hist=data_obs.key_nominal_hist
key_systematic_hist=data_obs.key_systematic_hist
if not file=="" and not key_nominal_hist=="" and not key_systematic_hist=="":
line.append(self.write_keyword_block_line(process_name=data_obs.name,category_name=category.name,file=file,
nominal_key=key_nominal_hist,syst_key=key_systematic_hist,size=size,sizekeys=sizekeys))
return line

def write_keyword_block_line(self, process_name, category_name, file,
Expand Down Expand Up @@ -286,6 +294,11 @@ def get_max_size_keys(self,analysis):
keynames.append(process.file)
keynames.append(process.key_nominal_hist)
keynames.append(process.key_systematic_hist)
process=analysis[category_name].observation
if not process is None:
keynames.append(process.file)
keynames.append(process.key_nominal_hist)
keynames.append(process.key_systematic_hist)
keynames = [x for x in keynames if x != "" and not x is None]
return len(max(keynames,key=len))

Expand Down
4 changes: 3 additions & 1 deletion src/processObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class processObject(object):
_id_logic = identificationLogic()
identificationLogic.belongs_to = "process"
_value_rules = valueConventions()
_file_handler = fileHandler()


def init_variables(self):
self._name = ""
Expand All @@ -24,6 +24,7 @@ def init_variables(self):
self._uncertainties = {}
self._debug = 0
self._calculate_yield = False
self._file_handler = fileHandler()


def __init__( self, processName = None, pathToRootfile = None,
Expand Down Expand Up @@ -126,6 +127,7 @@ def file(self, rootpath):
print "setting filepath to", rootpath
if path.exists(rootpath):
self._file_handler.filepath = rootpath
self.eventcount = self.calculate_yield()
else:
print "file '%s' does not exist!" % rootpath

Expand Down

0 comments on commit d278321

Please sign in to comment.