Source code for mermithid.processors.IO.IOCicadaProcessor

'''
Processor that can read (not write) Katydid ROOT files using the Cicada library
Author: M. Guigue
Date: Mar 30 2018
'''

from morpho.processors.IO import IOProcessor
from morpho.utilities import reader, morphologging
logger = morphologging.getLogger(__name__)

try:
    from ROOT import TFile, TTreeReader, TTreeReaderValue
except ImportError:
    pass

[docs]class IOCicadaProcessor(IOProcessor): ''' Processor that can read (not write) Katydid ROOT files using the Cicada library '''
[docs] def InternalConfigure(self,params): ''' Args: object_type: class of the object to read in the file object_name: name of the tree followed by the name of the object use_katydid: retro-compatibility to Katydid namespace ''' super().InternalConfigure(params) self.object_type = reader.read_param(params,"object_type","TMultiTrackEventData") self.object_name = reader.read_param(params,"object_name","multiTrackEvents:Event") self.use_katydid = reader.read_param(params,"use_katydid",False) return True
[docs] def Reader(self): ''' Reader method ''' logger.debug("Reading {}".format(self.file_name)) try: from ReadKTOutputFile import ReadKTOutputFile except ImportError: logger.warn("Cannot import ReadKTOutputFile") self.data = ReadKTOutputFile(self.file_name,self.variables,katydid=self.use_katydid,objectType=self.object_type,name=self.object_name) return True
[docs] def Writer(self): ''' End-user analysis should not produce Katydid output objects... ''' logger.error("End user analysis: cannot write reconstruction algorithm output") raise