R__unzip: error in header: monitoring DAQ

Hi,

I want to write a DAQ software storing the output data in a root tree. To be able to look at the data during a run (for monitoring), I am saving the tree every 10000 events with AutoSave:

I am testing it at the moment with my simulation package. While the simulation is running, the tree is being written in the output file “a” every 10000 events. At the same time as the simulation runs, I open in another terminal a new root session to open the “a” file and extract the tree to make some analysis, so I do:

TFile *a = new TFile("test.root")
TTree *t = (TTree*)a->Get("t1") 

I can open the file, and I see that the tree is inside. But in the second line, when I try to get the tree, it does not work and I get the following error:

The error happens about 80% of the times, not always. If I make my simulation to crash, then I can extract the tree with the last saved data also without errors. So my guess is that the error is produced when I am trying to read the tree at the same time as the simulation is writing it into the file.

Is there a safe way of extracting a tree from a file at the same time as it is being updated, so that this error does not appear?

Thanks for your attention,
Estela.

What is “t1”/ a TTree ? a class deriving from TTree? why t1->fChain?
When reading the Tree, I see tha you Get(“t1”)!
See also teh doc and example given in TTree::AutoSave

Rene

Hi,

sorry, I’ll explain.

“t1” is a tree from a “t1sim.cc” class that I defined myself. The class defines the names of all branches and their structure. It also states that the name of the tree is “t1”. In this way I do not need to declare all branches in my routines, but just call the class. This is also the reason why when calling AutoSave I need to use “fChain”.

For reading the tree from another session, I was working just in command line and I wanted only to plot the content of one branch. So instead of making the declaration of the tree as:

t1sim *t = new t1sim((TTree*)a->Get("t1"))
I made directly:

TTree *t = (TTree*)a->Get("t1")

If you think that this could be the cause of the error, I’ll test again using the class declaration. I’ll let you know the output in some minutes.

I’ve checked the TTree::AutoSave description, but what’s written there seems to be the same that I do, concerning the oppening and usage of the tree:

TFile f("test.root");
TTree *ntuple = (TTree*)f.Get("ntuple")

Cheers,
Estela.

Hi again,

I observe the same behavior when using the class:

#include <t1sim.cc> TFile *a = new TFile("test.root") t1sim *t = new t1sim((TTree*)a->Get("t1")) R__unzip: error in header

As before, the error does not appear all the time, but very frequently.

Any idea of what am I doing wrong?

Cheers,
Estela.

Could you indicate your ROOT version number?
How long does it take for the producer to make 10000 events? 1ms, 1s, 1h ?

Rene

Hi,

my root version is root5.20.
And it takes about 5 seconds to run 10000 events.

Cheers,
Estela.

OK, so my recommendations:
-move to a more recent version. The “saveself” was not implemented in your version.
-reduce the frequency of calls to AutoSave
-on the client ROOT session, use TTree::Refresh whenever you want to have another look at your data. This is much better than opening the file every time. (as shown in the doc of AutoSave)

Rene

Ok, I’ll do so. Thanks!