Skip to content

bugfix in some macros: save RTDB after the run initialization

Sergey Gorbunov requested to merge se.gorbunov/cbmroot:parfile into master

Bug fix in some macros that look "official" to me. The other 350 macros should be probably fixed by their authors.

The problem I found is that the FairRuntimeDb::saveOutput() does not work when FairRunAna is not initialized.

Here is the typical case:

  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
  parOut->open(parFile.Data());
  rtdb->setOutput(parOut);
  rtdb->saveOutput();
  rtdb->print();

 ..

  run->Run(..);

Here rtdb->saveOutput(); writes an empty file. One should call it after run->Init() or after run->Run().

Why it happens:

In principle, there is no need to call the rtdb->saveOutput(). Once the output file is set, the FairRuntimeDb is supposed to save the database automatically. It internally calls saveOutput() whenever the run number changes + at the end of the data processing, namely in the FairRuntimeDb destructor.

The problem is that in our macros, the FairRuntimeDb destructor is never called since we never care to delete the database or the run objects. Therefore, the database is not automatically written at the end.

To get around this problem, we call the rtdb->saveOutput() explicitly. But this approach only works when the run is already initialized, i.e., after run->Init();

I think the best place to call the rtdb->saveOutput() is not after run->Init() but at the very end, after run->Run(). This solution works for the case when the run number changes during the reconstruction.

Merge request reports