Skip to content

Problems with calling factories directly #979

@sdobbs

Description

@sdobbs

The is a pattern used in various places in the current code which may be causing a problem. In this pattern, factories or plugins will directly access factory objects to use some convenience functions, which can cause a problem.

As an example, inside JEventProcessor_RF_online::Process(), there is the line auto dRFTimeFactory = static_cast<DRFTime_factory*>(locEvent->GetFactory("DRFTime", ""));. Some convenience functions are called from dRFTimeFactory later on (mostly for shifting times by a certain number of beam bunches). However, the functions rely on some CCDB parameters, which are loaded in DRFTime_factory::BeginRun(). It turns out that sometimes this is not being called, which causes the calculation to not work properly.

The question I have is how best to address this problem.

Right now, I can solve it by calling DRFTime_factory::BeginRun() by hand in JEventProcessor_RF_online:: BeginRun(), which is ok since DRFTime_factory::BeginRun() can be called multiple times, nothing bad happens. It's not a great solution though.

The other possible options that I see are:
(1) finding some way to make sure that these factories are properly initialized beforehand - like maybe I need to Get() the DRFTime objects, even if I might not be using them in this processor?
(2) move the convenience functions out into their own objects - some extra code is needed for this, but conceptually is probably cleaner

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions