art module in Python
I would like to be able to write an EDAnalyzer in python. The initial work is available in artextensions on branch feature/pymod, in directory artextensions/PyMod. The interfaces are defined here. This work requires issue 11026. This is part of the usability issues at https://cdcvs.fnal.gov/redmine/projects/cet-is-private/wiki/IdeasForUsability. Only the NTuple product from issue 11026 needs to be supported; the initial work demonstrates this.
Here are the issues that need to be sorted out (or at least reviewed) to complete this work:
- need to make sure that the python path is set correctly so that the python module code is picked up properly when the art executable is run
- requires that no build step be necessary to run art and pick up newly edited python module code.
Here is a partial example module (from PyMod) of an art module written in Python.
class MyModule(art_services.Analyzer): def __init__(self, pset): super(MyModule,self).__init__(pset) self.name = pset['module_name'] self.label = pset['label'] self.registerHist(TH1F("Puker1","Duke1",15,0,1.3)) self.registerHist(TH1F("Puker2","Duke2",10,0,1.5)) self.registerHist(TH1F("Puker3","Duke3",15,0,1.3)) def analyze(self,event): print "in mymodule analyze", self.name prod = art_services.event_get(event,self.label) print prod all = art_services.extract_all(prod) print all.b b = all.a * all.b self.Puker1.Fill(all.a) self.Puker2.Fill(all.a) self.Puker3.Fill(all.c) return 0 def endJob(self): print "in endJob of MyModule" return 0