[ROOT] How to use vector in Event?

From: Alexander Bürger (buerger@iskp.uni-bonn.de)
Date: Wed Sep 03 2003 - 04:04:58 MEST


Hi,

to put my Events into a Tree I have a class similar to the following:

class TEvent {
	int count;
	float *time; //[count];
};

I like this, because in the tree viewer I can click and I get a nice time
spectrum. Unfortunately, I made some mistake in memory allocation so that
when I used TChain to chain several files, I did not get spectra, but only
segfaults, while with a single TFile it was working.

Before fixing the problem I tried to use a class like

class TEvent {
	int count;
	std::vector<float> time; //[count]
};

to circumvent manual memory allocation and also to avoid re-allocation of
the array for each event in reading from the tree. But I did not get this
to work in the tree viewer: the time spectrum just showed zeroes.

How can I use the vector<> in a way compatible with the tree viewer?

Best wishes, and thanks for your help,

Alexander



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET