Re-implementing BeginOfEventProcess?

Hi, I see few processes in the repository are re-implementing the method BeginOfEventProcess and EndOfEventProcess. From the last update I don’t remember now how this should be.

Should we avoid to re-implement the method BeginOfEventProcess in any specific process? What happens with the BeginOfEventProcess defined in few processes in the repository? Are they just ignored?

I don’t understand a basic c++ question, since now TRestEventProcess::BeginOfEventProcess is not virtual in TRestEventProcess, why the compilation does not complain when the method is re-implemented in a derived class?

I have not implemented any process but as I read them I understood that the way to work with processes was in fact to redefine BeginOfEventProcess and EndOfEventProcess in each new process.

This is just method overriding in C++, you can redefine any method of a derived class and it will take preference over the same method on the base class. I am not 100% sure on the virtual keyword but I think it allows you to call the base class function in the derived class function (not sure though).

I believe this is the old way, I believe now we do not have to implement it (while before it was mandatory). Probably if BeginOfEventProcess is virtual the compiler will not complain if the method is not directly implemented in TRestEventProcess that may do the difference between virtual or not.

I believe, BeginOfEventProcess is optional now, but we must call TRestEventProcess::BeginOfEventProcess() inside the re-implemented BeginOfEventProcess.

But some of the processes inside the repository, i.e. TRestHitsToTrackProcess between others, in the implementation do not follow that rule.

That’s why I am trying to re-call how this should be. I imagine we need to update those methods, if not the mechanism of transferring eventId, runId, etc, will not work properly. I am right @nkx?

If the method is not virtual, and you still implement it in the derived class, then, if we write:

DerivedClass* dc=new DerivedClass();
BaseClass* bc=dc;
dc->Method(); //call the derived class's implementation
bc->Method(); //call the base class's implementation

In our process executor(TRestProcessRunner), we save the dedicated process instance as base class TRestEventProcess, so, the call of their BeginOfEventProcess() is in the second form. When writing the process, if you implement BeginOfEventProcess(), it changes nothing.

Now the event initialization and auto run-info assignment is done in TRestEvenProcess::BeginOfEventProcess(). For TRestHitsToTrackProcess the old implemented BeginOfEventProcess() can be replaced, since it is only doing event initialization. I have checked all the processes at that time. I think the new TRestEvenProcess::BeginOfEventProcess() is capable for replacing all the old implemented BeginOfEventProcess().

Content of BeginOfEventProcess().txt (5.9 KB)

Then, I understand all of them Begin,EndOfEventProcess do not harm but they should be removed to avoid confusion in future.

1 Like