HOWTO add private code to a DANA application

From GlueXWiki
Revision as of 10:03, 31 March 2010 by Marki (Talk | contribs) (first draft)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

hd_ana and other DApps, in and of themselves, will not call any user code. To introduce user code one needs to write a class which derives from JEventProcessor and then register that class with the DApplication.

The JEventProcessor-inheriting class, let's call it MyProcessor, contains methods which include:

  • init called at initialization time
  • fini called at end of processing
  • brun called at the beginning of each run
  • erun called at the end of each run
  • evnt called for every event

Registration can be done with the AddProcessor method of the DApplication. For example:

int main(int narg, char *argv[])
{
   // Instantiate an event loop object
   DApplication app(narg, argv);

   // Register private code with the application
   app.AddProcessor(new MyProcessor());

   // Run though all events
   app.Run(NULL, 1);

   return 0;
}

Note that you can have as many processors as you would like. Each one must be instantiated and its pointer used to register it with the application.

See the section on Event Processors in the JANA manual for more details.