Source code for pydiana.tools.globals

from pydiana import ROOT,Diana,diana_install,diana_ext_install
[docs] def GetSampleInfoEventTypeDict(): """ Function for automatically reading QSampleInfo::EventType enumerator for pretty conversion. Slightly deprecated Returns ------- dictionary with int of the enumerator as key and enumerator string as values """ path2SamplInfo = diana_install+"/pkg/dianadata/QSampleInfo.hh" file_contents="" with open(path2SamplInfo, 'r') as file: # Read the entire file contents into a string file_contents = file.read() file_contents= file_contents.split("\n") enumerator = [] read = False for ll in file_contents: if 'enum' in ll and '@' not in ll: read = True if read and '}' in ll: read = False if read: enumerator.append(ll) enumerator = enumerator[1:] enumerator = [e.split(',')[0] for e in enumerator] enumerator = [e.split('/*')[0] for e in enumerator] enumerator = {int(e.split('=')[-1]):"".join(e.split('=')[0].split(" ")) for e in enumerator} return enumerator
qsampleinfoeventtype = GetSampleInfoEventTypeDict()